Unable to register models on django 1.9
See original GitHub issueThe example in the documentation throws the following exception in django 1.9:
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/rob/code/abett.api/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
utility.execute()
File "/Users/rob/code/abett.api/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 342, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/rob/code/abett.api/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 176, in fetch_command
commands = get_commands()
File "/Users/rob/code/abett.api/env/lib/python2.7/site-packages/django/utils/lru_cache.py", line 100, in wrapper
result = user_function(*args, **kwds)
File "/Users/rob/code/abett.api/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 71, in get_commands
for app_config in reversed(list(apps.get_app_configs())):
File "/Users/rob/code/abett.api/env/lib/python2.7/site-packages/django/apps/registry.py", line 137, in get_app_configs
self.check_apps_ready()
File "/Users/rob/code/abett.api/env/lib/python2.7/site-packages/django/apps/registry.py", line 124, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
I get this exception if I try to use the <1.7 example from the docs:
Traceback (most recent call last):
File "/Users/rob/code/abett.api/env/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/Users/rob/code/abett.api/env/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/Users/rob/code/abett.api/env/lib/python2.7/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception
six.reraise(*_exception)
File "/Users/rob/code/abett.api/env/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/Users/rob/code/abett.api/env/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/rob/code/abett.api/env/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/Users/rob/code/abett.api/env/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Users/rob/code/abett.api/abett/api/models.py", line 9, in <module>
registry.register('Friendship')
File "/Users/rob/code/django-activity-stream/actstream/registry.py", line 93, in register
model_class = validate(class_or_label)
File "/Users/rob/code/django-activity-stream/actstream/registry.py", line 73, in validate
model_class = get_model(*model_class.split('.'))
File "/Users/rob/code/abett.api/env/lib/python2.7/site-packages/django/apps/registry.py", line 194, in get_model
self.check_models_ready()
File "/Users/rob/code/abett.api/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.
Issue Analytics
- State:
- Created 8 years ago
- Comments:10
Top Results From Across the Web
why i can't register my Django App models on the admin site?
Change the import from "app.models" to just ".models" because they are in the same directory and see.
Read more >Applications - Django documentation
Django contains a registry of installed applications that stores configuration and provides introspection. It also maintains a list of available models.
Read more >Writing your first Django app, part 1 - Django documentation
The first step in writing a database Web app in Django is to define your models – essentially, your database layout, with additional...
Read more >Settings - Django documentation
Core Settings¶. Here's a list of settings available in Django core and their default values. Settings provided by contrib apps are listed below, ......
Read more >System check framework | Django documentation
System check framework¶. The system check framework is a set of static checks for validating Django projects. It detects common problems and provides...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I worked around this by moving
from actstream import registry
inside the ready function.Was getting the same error moving
import actstream import registry
along with some other imports inside the ready function worked.