|
1 | | -import django |
2 | 1 | from django.conf import settings |
3 | | -from django.core.exceptions import ImproperlyConfigured |
4 | | -from django import template |
5 | 2 |
|
6 | 3 | SOCIALACCOUNT_ENABLED = 'allauth.socialaccount' in settings.INSTALLED_APPS |
7 | 4 |
|
8 | | - |
9 | | -def check_context_processors(): |
10 | | - allauth_ctx = 'allauth.socialaccount.context_processors.socialaccount' |
11 | | - ctx_present = False |
12 | | - |
13 | | - if django.VERSION < (1, 8,): |
14 | | - setting = "settings.TEMPLATE_CONTEXT_PROCESSORS" |
15 | | - if allauth_ctx in settings.TEMPLATE_CONTEXT_PROCESSORS: |
16 | | - ctx_present = True |
17 | | - else: |
18 | | - for name, engine in template.engines.templates.items(): |
19 | | - if allauth_ctx in engine.get('OPTIONS', {})\ |
20 | | - .get('context_processors', []): |
21 | | - ctx_present = True |
22 | | - else: |
23 | | - setting = "settings.TEMPLATES['{}']['OPTIONS']['context_processors']" |
24 | | - setting = setting.format(name) |
25 | | - |
26 | | - if not ctx_present: |
27 | | - excmsg = ("socialaccount context processor " |
28 | | - "not found in {}. " |
29 | | - "See settings.py instructions here: " |
30 | | - "http://django-allauth.readthedocs.org/en/latest/installation.html") |
31 | | - raise ImproperlyConfigured(excmsg.format(setting)) |
32 | | - |
33 | | - |
34 | | -if SOCIALACCOUNT_ENABLED: |
35 | | - check_context_processors() |
36 | | - |
37 | | - |
38 | 5 | LOGIN_REDIRECT_URL = getattr(settings, 'LOGIN_REDIRECT_URL', '/') |
39 | 6 |
|
40 | 7 | USER_MODEL = getattr(settings, 'AUTH_USER_MODEL', 'auth.User') |
0 commit comments