{"action":"created","issue":{"url":"https://api.github.com/repos/dokterbob/django-newsletter/issues/147","labels_url":"https://api.github.com/repos/dokterbob/django-newsletter/issues/147/labels{/name}","comments_url":"https://api.github.com/repos/dokterbob/django-newsletter/issues/147/comments","events_url":"https://api.github.com/repos/dokterbob/django-newsletter/issues/147/events","html_url":"https://github.com/dokterbob/django-newsletter/pull/147","id":116172116,"number":147,"title":"Import User the 1.7 way.","user":{"login":"sandino","id":1300578,"avatar_url":"https://avatars.githubusercontent.com/u/1300578?v=3","gravatar_id":"","url":"https://api.github.com/users/sandino","html_url":"https://github.com/sandino","followers_url":"https://api.github.com/users/sandino/followers","following_url":"https://api.github.com/users/sandino/following{/other_user}","gists_url":"https://api.github.com/users/sandino/gists{/gist_id}","starred_url":"https://api.github.com/users/sandino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sandino/subscriptions","organizations_url":"https://api.github.com/users/sandino/orgs","repos_url":"https://api.github.com/users/sandino/repos","events_url":"https://api.github.com/users/sandino/events{/privacy}","received_events_url":"https://api.github.com/users/sandino/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-11-10T18:31:30Z","updated_at":"2016-01-03T11:32:16Z","closed_at":"2016-01-03T11:32:16Z","pull_request":{"url":"https://api.github.com/repos/dokterbob/django-newsletter/pulls/147","html_url":"https://github.com/dokterbob/django-newsletter/pull/147","diff_url":"https://github.com/dokterbob/django-newsletter/pull/147.diff","patch_url":"https://github.com/dokterbob/django-newsletter/pull/147.patch"},"body":"Sometimes User model cannot be imported this way (Django 1.8.6, Python 2.7.10):\r\n\r\n    (venv)[20:51]est@14_04:/home/django/zyq2/zyq2$ ./manage.py check\r\n    Traceback (most recent call last):\r\n    File \"./manage.py\", line 10, in <module>\r\n        execute_from_command_line(sys.argv)\r\n    File \"/home/django/zyq2/env/lib/python2.7/site-packages/django/core/management/__init__.py\", line 354, in execute_from_command_line\r\n        utility.execute()\r\n    File \"/home/django/zyq2/env/lib/python2.7/site-packages/django/core/management/__init__.py\", line 328, in execute\r\n        django.setup()\r\n    File \"/home/django/zyq2/env/lib/python2.7/site-packages/django/__init__.py\", line 18, in setup\r\n        apps.populate(settings.INSTALLED_APPS)\r\n    File \"/home/django/zyq2/env/lib/python2.7/site-packages/django/apps/registry.py\", line 108, in populate\r\n        app_config.import_models(all_models)\r\n    File \"/home/django/zyq2/env/lib/python2.7/site-packages/django/apps/config.py\", line 198, in import_models\r\n        self.models_module = import_module(models_module_name)\r\n    File \"/home/est/.pyenv/versions/2.7.10/lib/python2.7/importlib/__init__.py\", line 37, in import_module\r\n        __import__(name)\r\n    File \"/home/django/zyq2/env/lib/python2.7/site-packages/newsletter/models.py\", line 26, in <module>\r\n        User = get_user_model()\r\n    File \"/home/django/zyq2/env/lib/python2.7/site-packages/newsletter/utils.py\", line 35, in get_user_model\r\n        User = get_user_model()\r\n    File \"/home/django/zyq2/env/lib/python2.7/site-packages/django/contrib/auth/__init__.py\", line 150, in get_user_model\r\n        return django_apps.get_model(settings.AUTH_USER_MODEL)\r\n    File \"/home/django/zyq2/env/lib/python2.7/site-packages/django/apps/registry.py\", line 199, in get_model\r\n        self.check_models_ready()\r\n    File \"/home/django/zyq2/env/lib/python2.7/site-packages/django/apps/registry.py\", line 131, in check_models_ready\r\n        raise AppRegistryNotReady(\"Models aren't loaded yet.\")\r\n    django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.\r\n\r\nImporting `User` as `settings.AUTH_USER_MODEL` solves the problem."},"comment":{"url":"https://api.github.com/repos/dokterbob/django-newsletter/issues/comments/168490142","html_url":"https://github.com/dokterbob/django-newsletter/pull/147#issuecomment-168490142","issue_url":"https://api.github.com/repos/dokterbob/django-newsletter/issues/147","id":168490142,"user":{"login":"dokterbob","id":22742,"avatar_url":"https://avatars.githubusercontent.com/u/22742?v=3","gravatar_id":"","url":"https://api.github.com/users/dokterbob","html_url":"https://github.com/dokterbob","followers_url":"https://api.github.com/users/dokterbob/followers","following_url":"https://api.github.com/users/dokterbob/following{/other_user}","gists_url":"https://api.github.com/users/dokterbob/gists{/gist_id}","starred_url":"https://api.github.com/users/dokterbob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dokterbob/subscriptions","organizations_url":"https://api.github.com/users/dokterbob/orgs","repos_url":"https://api.github.com/users/dokterbob/repos","events_url":"https://api.github.com/users/dokterbob/events{/privacy}","received_events_url":"https://api.github.com/users/dokterbob/received_events","type":"User","site_admin":false},"created_at":"2016-01-03T11:32:16Z","updated_at":"2016-01-03T11:32:16Z","body":"AFAIK this patch has become redundant due to us only supporting Django => 1.8 now.\r\n\r\nHowever, the legacy code/wrapper still needs to be removed. For this I created #161."}}