Skip to content

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

@johnthedebs

Description

@johnthedebs

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions