-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Socialaccount: replaced context processor with template tag
Fixes #949.
- Loading branch information
Showing
10 changed files
with
40 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,7 @@ | ||
import django | ||
from django.conf import settings | ||
from django.core.exceptions import ImproperlyConfigured | ||
from django import template | ||
|
||
SOCIALACCOUNT_ENABLED = 'allauth.socialaccount' in settings.INSTALLED_APPS | ||
|
||
|
||
def check_context_processors(): | ||
allauth_ctx = 'allauth.socialaccount.context_processors.socialaccount' | ||
ctx_present = False | ||
|
||
if django.VERSION < (1, 8,): | ||
setting = "settings.TEMPLATE_CONTEXT_PROCESSORS" | ||
if allauth_ctx in settings.TEMPLATE_CONTEXT_PROCESSORS: | ||
ctx_present = True | ||
else: | ||
for name, engine in template.engines.templates.items(): | ||
if allauth_ctx in engine.get('OPTIONS', {})\ | ||
.get('context_processors', []): | ||
ctx_present = True | ||
else: | ||
setting = "settings.TEMPLATES['{}']['OPTIONS']['context_processors']" | ||
setting = setting.format(name) | ||
|
||
if not ctx_present: | ||
excmsg = ("socialaccount context processor " | ||
"not found in {}. " | ||
"See settings.py instructions here: " | ||
"http://django-allauth.readthedocs.org/en/latest/installation.html") | ||
raise ImproperlyConfigured(excmsg.format(setting)) | ||
|
||
|
||
if SOCIALACCOUNT_ENABLED: | ||
check_context_processors() | ||
|
||
|
||
LOGIN_REDIRECT_URL = getattr(settings, 'LOGIN_REDIRECT_URL', '/') | ||
|
||
USER_MODEL = getattr(settings, 'AUTH_USER_MODEL', 'auth.User') |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7a5838b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recently reinstalled django and all other django apps and I didn't notice this package has been upgraded. My django project kept reporting "No module named context_processors". Thank god I finally found this and removed allauth specific context processors from settings.py.
7a5838b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@huangtao800 I am sorry you bumped into this.. do note that it was documented: https://django-allauth.readthedocs.org/en/latest/changelog.html#from-0-21-0