jedie / django-tools

miscellaneous django tools
http://pypi.python.org/pypi/django-tools/
Other
128 stars 31 forks source link

Adding django_tools.dynamic_site to INSTALLED_APPS fails with "Models aren't loaded yet." #6

Open kitsunde opened 9 years ago

kitsunde commented 9 years ago

I'm using Django 1.7.5 and when I tried adding django_tools.dynamic_site to the project it failed with:

$ src/landrover/manage.py runserver
Traceback (most recent call last):
  File "src/landrover/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/kitsunde/.virtualenvs/landrover/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/Users/kitsunde/.virtualenvs/landrover/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
    django.setup()
  File "/Users/kitsunde/.virtualenvs/landrover/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/kitsunde/.virtualenvs/landrover/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "/Users/kitsunde/.virtualenvs/landrover/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/Users/kitsunde/.virtualenvs/landrover/lib/python2.7/site-packages/django_tools/dynamic_site/models.py", line 31, in <module>
    from django_tools.models import UpdateInfoBaseModel
  File "/Users/kitsunde/.virtualenvs/landrover/lib/python2.7/site-packages/django_tools/models.py", line 26, in <module>
    User = auth.get_user_model()
  File "/Users/kitsunde/.virtualenvs/landrover/lib/python2.7/site-packages/django/contrib/auth/__init__.py", line 137, in get_user_model
    return django_apps.get_model(settings.AUTH_USER_MODEL)
  File "/Users/kitsunde/.virtualenvs/landrover/lib/python2.7/site-packages/django/apps/registry.py", line 199, in get_model
    self.check_models_ready()
  File "/Users/kitsunde/.virtualenvs/landrover/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.
jedie commented 9 years ago

Thank you, for reporting this.

Please test the develop branch.

I commit https://github.com/jedie/django-tools/commit/10bfd69a9b6e1d9edea4b6384c058f12568d97cb that should be fix that!