Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using UserSocialAuth model with Django's generic FKs breaks #38

Closed
johnthedebs opened this issue Sep 25, 2013 · 2 comments
Closed

Using UserSocialAuth model with Django's generic FKs breaks #38

johnthedebs opened this issue Sep 25, 2013 · 2 comments

Comments

@johnthedebs
Copy link

I recently upgraded from django-social-auth to python-social-auth (version 0.1.12) and a bit of code that had worked before is no longer working. I've got a model that points to UserSocialAuth or one of my own custom models through a generic FK, and it throws an error when I try to access it.

Here is the traceback I get (and please let me know if there's any other information I could provide that would be helpful):

Traceback (most recent call last):
File "/var/venvs/project_name/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 115, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
File "/var/venvs/project_name/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py", line 25, in _wrapped_view
    return view_func(request, *args, **kwargs)
File "/var/venvs/project_name/local/lib/python2.7/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
File "/var/venvs/project_name/local/lib/python2.7/site-packages/django/views/generic/base.py", line 86, in dispatch
    return handler(request, *args, **kwargs)
File "/var/venvs/project_name/local/lib/python2.7/site-packages/django/views/generic/edit.py", line 218, in get
    return super(BaseUpdateView, self).get(request, *args, **kwargs)
File "/var/venvs/project_name/local/lib/python2.7/site-packages/django/views/generic/edit.py", line 154, in get
    form = self.get_form(form_class)
File "/var/sites/project_name/project_name/user_settings/views.py", line 102, in get_form
    return form_class(self.request.user, **self.get_form_kwargs())
File "/var/sites/project_name/project_name/user_settings/forms.py", line 75, in __init__
    if user.fb_account:
File "/var/venvs/project_name/local/lib/python2.7/site-packages/django/utils/functional.py", line 205, in inner
    return func(self._wrapped, *args)
File "/var/venvs/project_name/local/lib/python2.7/site-packages/django/contrib/contenttypes/generic.py", line 124, in __get__
    ct = self.get_content_type(id=ct_id, using=instance._state.db)
File "/var/venvs/project_name/local/lib/python2.7/site-packages/django/contrib/contenttypes/generic.py", line 60, in get_content_type
    return ContentType.objects.db_manager(using).get_for_id(id)
File "/var/venvs/project_name/local/lib/python2.7/site-packages/django/contrib/contenttypes/models.py", line 107, in get_for_id
    self._add_to_cache(self.db, ct)
File "/var/venvs/project_name/local/lib/python2.7/site-packages/django/contrib/contenttypes/models.py", line 122, in _add_to_cache
    key = (model._meta.app_label, model._meta.object_name.lower())
AttributeError: 'NoneType' object has no attribute '_meta'
@omab
Copy link
Owner

omab commented Sep 25, 2013

Could you list the content-types in registered in your app? I think that the CT for UserSocialAuth changed since the app name change on PSA.

@johnthedebs
Copy link
Author

Looks like you've found the issue - I have two user social auth CTs in the DB, and one of them doesn't return a model when its model_class() method is called. That explains why the code works when I leave in the old import. Thanks!

@omab omab closed this as completed Nov 9, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants