Question

I am porting a project from using django-social-auth to python-social-auth. I followed the instructions in the documentation, but when I try to run the project's test (./manage.py test) I get the following error:

Creating test database for alias 'default' ...
CommandError: One or more models did not validate:
default.usersocialauth: Accessor for field 'user' clashes with related field 'User.social_auth'. Add a related_name argument to the definition for 'user'.
default.usersocialauth: Reverse query name for field 'user' clashes with related field 'User.social_auth'. Add a related_name argument to the definition for 'user'.

./manage.py syncdb and ./manage migrate work fine, as expected, because (as the documentation states), the models table names in python-social-auth were defined to be compatible with those used on django-social-auth, so data is not needed to be migrated.

Was it helpful?

Solution

Ran into same issue.

Even though django-social-auth library was removed from INSTALLED_APPS, django was still finding the conflict since both django-social-auth and python-social-auth use same foreign keys with same related_name parameter.

To know exactly what model is python-social-auth is clashing with, put a breakpoint in

get_validation_errors (validation.py)

on line 148 and 150

for r in rel_opts.get_all_related_objects():
    if r.field is not f:
        if r.get_accessor_name() == rel_name:
            e.add(opts, "Accessor for field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))
        if r.get_accessor_name() == rel_query_name:
            e.add(opts, "Reverse query name for field '%s' clashes with related field '%s.%s'. Add a related_name argument to the definition for '%s'." % (f.name, rel_opts.object_name, r.get_accessor_name(), f.name))

looking at 'r' variable will reveal the related object that is clashing.

Removing library django-social-auth completely from the system solved the issue.

Since it was originally installed with easy_install, I used rm -rf to remove it from site-packages, but also remember to remove the name from easy_install.pth

You can also use pip uninstall

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top