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

Import User the 1.7 way. #147

Closed
wants to merge 1 commit into from
Closed

Import User the 1.7 way. #147

wants to merge 1 commit into from

Conversation

sandino
Copy link

@sandino sandino commented Nov 10, 2015

Sometimes User model cannot be imported this way (Django 1.8.6, Python 2.7.10):

(venv)[20:51]est@14_04:/home/django/zyq2/zyq2$ ./manage.py check
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
File "/home/django/zyq2/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
    utility.execute()
File "/home/django/zyq2/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 328, in execute
    django.setup()
File "/home/django/zyq2/env/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
File "/home/django/zyq2/env/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
File "/home/django/zyq2/env/lib/python2.7/site-packages/django/apps/config.py", line 198, in import_models
    self.models_module = import_module(models_module_name)
File "/home/est/.pyenv/versions/2.7.10/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
File "/home/django/zyq2/env/lib/python2.7/site-packages/newsletter/models.py", line 26, in <module>
    User = get_user_model()
File "/home/django/zyq2/env/lib/python2.7/site-packages/newsletter/utils.py", line 35, in get_user_model
    User = get_user_model()
File "/home/django/zyq2/env/lib/python2.7/site-packages/django/contrib/auth/__init__.py", line 150, in get_user_model
    return django_apps.get_model(settings.AUTH_USER_MODEL)
File "/home/django/zyq2/env/lib/python2.7/site-packages/django/apps/registry.py", line 199, in get_model
    self.check_models_ready()
File "/home/django/zyq2/env/lib/python2.7/site-packages/django/apps/registry.py", line 131, in check_models_ready
    raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.

Importing User as settings.AUTH_USER_MODEL solves the problem.

@landscape-bot
Copy link

Code Health
Code quality remained the same when pulling 9ee3106 on sandino:master into 0664a3c on dokterbob:master.

@dokterbob
Copy link
Collaborator

Hey @sandino,

First of all, thanks for the contrib. However, it is not evident to me what issue this patch fixes, what versions of Django and Python it applies to and how it copes with compatibility issues.

If you look at the result of the CI here you can see that this patch breaks on all but the last 1.4 Django release. Hence, in its current form we are not able to accept it.

Please see if you can describe the issue more throughly, so other people who might suffer the same issue will find it here and might be able to provide more details on the issue. Even better would be a patch that doesn't break the tests while solving a well-documented/known issue. :)

Thanks in any case!
Mathijs

@dokterbob
Copy link
Collaborator

AFAIK this patch has become redundant due to us only supporting Django => 1.8 now.

However, the legacy code/wrapper still needs to be removed. For this I created #161.

@dokterbob dokterbob closed this Jan 3, 2016
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

Successfully merging this pull request may close these issues.

None yet

3 participants