omab / django-social-auth

Django social authentication made simple
https://groups.google.com/group/django-social-auth
BSD 3-Clause "New" or "Revised" License
2.65k stars 757 forks source link

ImportError: No module named loading with Django 1.10 #842

Closed cdman closed 7 years ago

cdman commented 8 years ago

Traceback:

Traceback (most recent call last):
  File "./manage.py", line 24, in <module>
    execute_from_command_line(sys.argv)
  File "[... redacted ...]/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "[... redacted ...]/django/core/management/__init__.py", line 341, in execute
    django.setup()
  File "[... redacted ...]/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "[... redacted ...]/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "[... redacted ...]/django/apps/config.py", line 199, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "[... redacted ...]/social_auth/models.py", line 6, in <module>
    from social_auth.utils import setting
  File "[... redacted ...]/social_auth/utils.py", line 14, in <module>
    from django.db.models.loading import get_model
ImportError: No module named loading

Apparently this was removed at the end of 2014: https://github.com/remohammadi/django/commit/4e65f195e1b10d83bb7edc38c908747c4fd537b8

A quick fix seems to be the following:

try:
    from django.db.models.loading import get_model
except ImportError:
    from django.apps import apps
    get_model = apps.get_model

Also, there seem to be other errors related to importlib (see #841) which can be fixed as:

try:
    from django.utils.importlib import import_module
except ImportError:
    import importlib

Generally it seems that django-social-auth is not well maintained and isn't compatible with Django 1.10