Skip to content

Commit

Permalink
Merge pull request #950 from pawciobiel/fix_for_fix_context_processor…
Browse files Browse the repository at this point in the history
…s_dj18

another fix for context processor socialaccount for django >= 1.8
  • Loading branch information
pennersr committed May 17, 2015
2 parents fe8c28e + b91315f commit 5782f05
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions allauth/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,31 @@

SOCIALACCOUNT_ENABLED = 'allauth.socialaccount' in settings.INSTALLED_APPS

if SOCIALACCOUNT_ENABLED:

def check_context_processors():
allauth_ctx = 'allauth.socialaccount.context_processors.socialaccount'
ctx_present = True
ctx_present = False

if django.VERSION < (1, 8,):
if allauth_ctx not in settings.TEMPLATE_CONTEXT_PROCESSORS:
ctx_present = False
if allauth_ctx in settings.TEMPLATE_CONTEXT_PROCESSORS:
ctx_present = True
else:
for engine in settings.TEMPLATES:
if allauth_ctx not in engine.get('OPTIONS', {})\
if allauth_ctx in engine.get('OPTIONS', {})\
.get('context_processors', []):
ctx_present = False
ctx_present = True
break

if not ctx_present:
raise ImproperlyConfigured("socialaccount context processor "
"not found in settings.TEMPLATE_CONTEXT_PROCESSORS."
"See settings.py instructions here: "
"https://github.com/pennersr/django-allauth#installation")
excmsg = ("socialaccount context processor "
"not found in settings.TEMPLATE_CONTEXT_PROCESSORS."
"See settings.py instructions here: "
"https://github.com/pennersr/django-allauth#installation")
raise ImproperlyConfigured(excmsg)


if SOCIALACCOUNT_ENABLED:
check_context_processors()


LOGIN_REDIRECT_URL = getattr(settings, 'LOGIN_REDIRECT_URL', '/')
Expand Down

0 comments on commit 5782f05

Please sign in to comment.