Apps aren't loaded yet.
See original GitHub issueHello,
I try to use this app but I have a problem with the configuration.
The name of my app : main_app
apps.py of main_app :
from django.apps import AppConfig
from actstream import registry
class MainAppConfig(AppConfig):
name = 'main_app'
def ready(self):
registry.register(self.get_model('Inscrit'))
init of main_app :
default_app_config = 'main_app.apps.MainAppConfig'
settings.py [Installed_apps] :
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'django.contrib.sites',
'bootstrapform',
'main_app',
'actstream',
]
I have this error :
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 342, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 176, in fetch_command
commands = get_commands()
File "/usr/local/lib/python2.7/dist-packages/django/utils/lru_cache.py", line 100, in wrapper
result = user_function(*args, **kwds)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 71, in get_commands
for app_config in reversed(list(apps.get_app_configs())):
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 137, in get_app_configs
self.check_apps_ready()
File "/usr/local/lib/python2.7/dist-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 read the #272 but it doesn’t help me…
BUT when I write from actstream import registry
inside def ready
, it works but why ? :octocat:
Issue Analytics
- State:
- Created 8 years ago
- Comments:12 (2 by maintainers)
Top Results From Across the Web
Django 1.7 upgrade error: AppRegistryNotReady: Apps aren't ...
Django 1.7 upgrade error: AppRegistryNotReady: Apps aren't loaded yet ... [client 95.79.172.156] raise AppRegistryNotReady("Models aren't loaded yet.
Read more >Django-error “AppRegistryNotReady: Apps aren't loaded yet
Photo by Faisal M on Unsplash. Found on stack overflow. The solution which worked for me is following import django django.setup()
Read more >Django scripting: “AppRegistryNotReady: Apps aren't loaded ...
Django scripting: “AppRegistryNotReady: Apps aren't loaded yet” solution! ... Don't panic! The solution is to run your application's setup() ...
Read more >otree zipserver gives "Apps aren't loaded yet." error
When I run the command "otree zipserver", I get the error below. I tried updating python, updating oTree, downgrading oTree but none seem...
Read more >Apps aren't loaded yet. (django 2.0.1)(Python - YouTube
Django : django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. (django 2.0.1)(Python 3.6) [ Beautify Your Computer ...
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 FreeTop 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
Top GitHub Comments
I remember having this issue. I think I just re-ordered
INSTALLED_APPS
a bit.tl;dr: the band-aid is to do something like this in your apps.py
Why? Because registry is not imported until ready() is called. If registry is imported beforehand, we see in @szechyjs 's stack trace that actstream.compat imports fields from django.contrib.contentypes. This module imports the model ContentType. See: https://docs.djangoproject.com/en/1.9/ref/applications/#how-applications-are-loaded . “In other words, your applications’ root packages and the modules that define your application configuration classes shouldn’t import any models, even indirectly.”
To completely fix this issue, we have to somehow prevent any other models imported indirectly before we can use actstream’s registry module.