From: Matías Aguirre Date: Mon, 29 Aug 2011 19:11:39 +0000 (-0300) Subject: Fix error on context processor. Closes gh-137. X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=c4ddcebb4a6d8ec8994df1bd92d5418fb880fc34;p=django-social-auth.git Fix error on context processor. Closes gh-137. --- diff --git a/social_auth/context_processors.py b/social_auth/context_processors.py index e905839..96f7c19 100644 --- a/social_auth/context_processors.py +++ b/social_auth/context_processors.py @@ -1,5 +1,6 @@ from social_auth.backends import BACKENDS from social_auth.utils import group_backend_by_type +from social_auth.models import User # Note: social_auth_backends and social_auth_by_type_backends don't play nice @@ -42,7 +43,9 @@ def backends_data(user): 'not_associated': available, 'backends': available} - if user.is_authenticated(): + # user comes from request.user usually, on /admin/ it will be an instance + # of auth.User and this code will fail if a custom User model was defined + if isinstance(user, User) and user.is_authenticated(): associated = user.social_auth.all() not_associated = list(set(available) - set(assoc.provider for assoc in associated))