omab/python-social-auth — pull request #46 by Markush2010 (2013-10-04 13:40:01+00:00)
Title: Fixes #45 -- AttributeError while resolving the user model in Django

Under some conditions ``UserSocialAuth._meta.get_field('user').rel.to`` does not return a Model class but a string of the form ``'.'``. This results in an AttributeError in the Django admin.py which ultimately triggers an error in Django's RegexURLResolver. This is fixed by properly resolving the user model and return a class rather than a string.

```ipdb
ipdb> /home/markus/Coding/python-social-auth/social/apps/django_app/default/admin.py(5)()
4
----> 5 from django.contrib import admin
6 from social.apps.django_app.default.models import UserSocialAuth, Nonce, \

ipdb> n
> /home/markus/Coding/python-social-auth/social/apps/django_app/default/admin.py(6)()
5 from django.contrib import admin
----> 6 from social.apps.django_app.default.models import UserSocialAuth, Nonce, \
7 Association

ipdb>
> /home/markus/Coding/python-social-auth/social/apps/django_app/default/admin.py(10)()
9
---> 10 _User = UserSocialAuth.user_model()
11
> /home/markus/Coding/python-social-auth/social/apps/django_app/default/models.py(59)user_model()
58
---> 59 @classmethod
60 def user_model(cls):

ipdb> n
> /home/markus/Coding/python-social-auth/social/apps/django_app/default/models.py(61)user_model()
60 def user_model(cls):
---> 61 return UserSocialAuth._meta.get_field('user').rel.to
62

ipdb> UserSocialAuth._meta

ipdb> UserSocialAuth._meta.get_field('user')

ipdb> UserSocialAuth._meta.get_field('user').rel

ipdb> UserSocialAuth._meta.get_field('user').rel.to
'auth.BakeryUser'
```