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

Error "imported before its application was loaded" #809

Closed
ckcollab opened this issue Dec 25, 2015 · 2 comments
Closed

Error "imported before its application was loaded" #809

ckcollab opened this issue Dec 25, 2015 · 2 comments

Comments

@ckcollab
Copy link
Contributor

Heyo! First of all: thanks for all of the hard work.

I'm trying to setup github oauth in my Django app, but I am getting this strange error...

RuntimeError: Model class social.apps.django_app.default.models.UserSocialAuth doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. 

I have the right stuff in installed apps (I believe) 'social.apps.django_app.default'

And I know I just recently used python-social-auth with 0 problems in another project, so I'm not sure what I may be doing wrong. I'm pretty confused because I see issues with people getting the same error (but as a warning?) and it seems to have been fixed?

Here's the complete error:

Not Found: /login/github
/Users/eric/.virtualenvs/3sc-api/lib/python3.5/site-packages/django/db/models/fields/subclassing.py:22: RemovedInDjango110Warning: SubfieldBase has been deprecated. Use Field.from_db_value instead.
  RemovedInDjango110Warning)

Internal Server Error: /login/github
Traceback (most recent call last):
  File "/Users/eric/.virtualenvs/3sc-api/lib/python3.5/site-packages/django/core/handlers/base.py", line 235, in get_response
    response = middleware_method(request, response)
  File "/Users/eric/.virtualenvs/3sc-api/lib/python3.5/site-packages/django/middleware/common.py", line 113, in process_response
    if self.should_redirect_with_slash(request):
  File "/Users/eric/.virtualenvs/3sc-api/lib/python3.5/site-packages/django/middleware/common.py", line 78, in should_redirect_with_slash
    and urlresolvers.is_valid_path('%s/' % request.path_info, urlconf)
  File "/Users/eric/.virtualenvs/3sc-api/lib/python3.5/site-packages/django/core/urlresolvers.py", line 668, in is_valid_path
    resolve(path, urlconf)
  File "/Users/eric/.virtualenvs/3sc-api/lib/python3.5/site-packages/django/core/urlresolvers.py", line 534, in resolve
    return get_resolver(urlconf).resolve(path)
  File "/Users/eric/.virtualenvs/3sc-api/lib/python3.5/site-packages/django/core/urlresolvers.py", line 376, in resolve
    sub_match = pattern.resolve(new_path)
  File "/Users/eric/.virtualenvs/3sc-api/lib/python3.5/site-packages/django/core/urlresolvers.py", line 376, in resolve
    sub_match = pattern.resolve(new_path)
  File "/Users/eric/.virtualenvs/3sc-api/lib/python3.5/site-packages/django/core/urlresolvers.py", line 248, in resolve
    return ResolverMatch(self.callback, args, kwargs, self.name)
  File "/Users/eric/.virtualenvs/3sc-api/lib/python3.5/site-packages/django/core/urlresolvers.py", line 255, in callback
    self._callback = get_callable(self._callback_str)
  File "/Users/eric/.virtualenvs/3sc-api/lib/python3.5/site-packages/django/core/urlresolvers.py", line 115, in get_callable
    mod = import_module(mod_name)
  File "/Users/eric/.virtualenvs/3sc-api/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 662, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/Users/eric/.virtualenvs/3sc-api/lib/python3.5/site-packages/social/apps/django_app/views.py", line 10, in <module>
    from social.apps.django_app.utils import psa
  File "/Users/eric/.virtualenvs/3sc-api/lib/python3.5/site-packages/social/apps/django_app/utils.py", line 21, in <module>
    Storage = module_member(STORAGE)
  File "/Users/eric/.virtualenvs/3sc-api/lib/python3.5/site-packages/social/utils.py", line 56, in module_member
    module = import_module(mod)
  File "/Users/eric/.virtualenvs/3sc-api/lib/python3.5/site-packages/social/utils.py", line 50, in import_module
    __import__(name)
  File "/Users/eric/.virtualenvs/3sc-api/lib/python3.5/site-packages/social/apps/django_app/default/models.py", line 67, in <module>
    class UserSocialAuth(AbstractUserSocialAuth):
  File "/Users/eric/.virtualenvs/3sc-api/lib/python3.5/site-packages/django/db/models/base.py", line 103, in __new__
    "application was loaded. " % (module, name))
RuntimeError: Model class social.apps.django_app.default.models.UserSocialAuth doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. 
[25/Dec/2015 03:18:06] "GET /login/github HTTP/1.1" 500 152175

@ckcollab
Copy link
Contributor Author

Hrm, I downgraded to Django 1.8 and I'm getting this
backend not found

When requesting http://localhost:8000/login/github/ OR http://localhost:8000/login/github-oauth2/

Using:

AUTHENTICATION_BACKENDS = (
    'social.backends.github.GithubOAuth2',
    'django.contrib.auth.backends.ModelBackend',
)

and

INSTALLED_APPS = (
    ...
    'social.apps.django_app.default',
)

@ckcollab
Copy link
Contributor Author

NOTE: For anyone who runs into this again.............. make sure you're working on the right settings.py ;)

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

1 participant