From c4ddcebb4a6d8ec8994df1bd92d5418fb880fc34 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mat=C3=ADas=20Aguirre?= Date: Mon, 29 Aug 2011 16:11:39 -0300 Subject: [PATCH] Fix error on context processor. Closes gh-137. --- social_auth/context_processors.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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)) -- 2.39.5