Skip to content

Fix AppRegistryNotReady error for panels that load models. #889

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

Merged
merged 1 commit into from
Oct 13, 2016

Conversation

vdboor
Copy link
Contributor

@vdboor vdboor commented Oct 13, 2016

The import to the debug_toolbar.middleware also loads all panels.
As a panel might be using Django models, such import happens too early.

This pull request moves the import statement so these errors won't occur.
The backtrace looks like:

File "django/__init__.py", line 18, in setup
  apps.populate(settings.INSTALLED_APPS)
File "django/apps/registry.py", line 85, in populate
  app_config = AppConfig.create(entry)
File "django/apps/config.py", line 116, in create
  mod = import_module(mod_path)
File "importlib/__init__.py", line 37, in import_module
  __import__(name)
File "debug_toolbar/apps.py", line 12, in <module>
  from debug_toolbar.middleware import DebugToolbarMiddleware
File "debug_toolbar/middleware.py", line 17, in <module>
  from debug_toolbar.toolbar import DebugToolbar
File "debug_toolbar/toolbar.py", line 151, in <module>
  urlpatterns = DebugToolbar.get_urls()
File "debug_toolbar/toolbar.py", line 145, in get_urls
  for panel_class in cls.get_panel_classes():
File "debug_toolbar/toolbar.py", line 118, in get_panel_classes
  mod = import_module(panel_module)
File "importlib/__init__.py", line 37, in import_module
  __import__(name)
File "fluent_contents/panels.py", line 7, in <module>
  from django.contrib.contenttypes.models import ContentType

The import to the debug_toolbar.middleware also loads all panels.
As a panel might be using Django models, such import happens too early.
@codecov-io
Copy link

codecov-io commented Oct 13, 2016

Current coverage is 77.00% (diff: 100%)

Merging #889 into master will not change coverage

@@             master       #889   diff @@
==========================================
  Files            30         30          
  Lines          1635       1635          
  Methods           0          0          
  Messages          0          0          
  Branches        244        244          
==========================================
  Hits           1259       1259          
  Misses          302        302          
  Partials         74         74          

Powered by Codecov. Last update 591ac03...9eb8932

@aaugustin aaugustin merged commit 5353ba6 into django-commons:master Oct 13, 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.

3 participants