Skip to content
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

Fix "RuntimeError: App registry isn't ready yet." with collectstatic #466

Conversation

blueyed
Copy link
Contributor

@blueyed blueyed commented Mar 22, 2014

When invoking collectstatic on a Django 1.7 beta installation, the
following error arises:

File "venv/local/lib/python2.7/site-packages/debug_toolbar/models.py", line 63, in <module>
  patch_root_urlconf()
File "venv/local/lib/python2.7/site-packages/debug_toolbar/models.py", line 51, in patch_root_urlconf
  reverse('djdt:render_panel')
File "venv/src/django/django/core/urlresolvers.py", line 490, in reverse
  app_list = resolver.app_dict[ns]
File "venv/src/django/django/core/urlresolvers.py", line 310, in app_dict
  self._populate()
File "venv/src/django/django/core/urlresolvers.py", line 264, in _populate
  for pattern in reversed(self.url_patterns):
File "venv/src/django/django/core/urlresolvers.py", line 348, in url_patterns
  patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "venv/src/django/django/core/urlresolvers.py", line 342, in urlconf_module
  self._urlconf_module = import_module(self.urlconf_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
  __import__(name)
File "/home/project/releases/master/project/config/urls.py", line 23, in <module>
  (r'^grappelli/', include('grappelli.urls')),
File "venv/src/django/django/conf/urls/__init__.py", line 28, in include
  urlconf_module = import_module(urlconf_module)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
  __import__(name)
File "venv/src/django-grappelli-25x/grappelli/urls.py", line 12, in <module>
  from .views.switch import switch_user
File "venv/src/django-grappelli-25x/grappelli/views/switch.py", line 18, in <module>
  User = get_user_model()
File "venv/src/django/django/contrib/auth/__init__.py", line 129, in get_user_model
  return django_apps.get_model(settings.AUTH_USER_MODEL)
File "venv/src/django/django/apps/registry.py", line 187, in get_model
  self.check_ready()
File "venv/src/django/django/apps/registry.py", line 119, in check_ready
  raise RuntimeError("App registry isn't ready yet.")

RuntimeError: App registry isn't ready yet.

This should probably use settings.AUTH_USER_MODEL in any case / or as fallback, but I was not sure how to handle it (seeing that django.utils.importlib is marked for deprecation already).

When invoking `collectstatic` on a Django 1.7 beta installation, the
following error arises:

  File "venv/local/lib/python2.7/site-packages/debug_toolbar/models.py", line 63, in <module>
    patch_root_urlconf()
  File "venv/local/lib/python2.7/site-packages/debug_toolbar/models.py", line 51, in patch_root_urlconf
    reverse('djdt:render_panel')
  File "venv/src/django/django/core/urlresolvers.py", line 490, in reverse
    app_list = resolver.app_dict[ns]
  File "venv/src/django/django/core/urlresolvers.py", line 310, in app_dict
    self._populate()
  File "venv/src/django/django/core/urlresolvers.py", line 264, in _populate
    for pattern in reversed(self.url_patterns):
  File "venv/src/django/django/core/urlresolvers.py", line 348, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "venv/src/django/django/core/urlresolvers.py", line 342, in urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/project/releases/master/project/config/urls.py", line 23, in <module>
    (r'^grappelli/', include('grappelli.urls')),
  File "venv/src/django/django/conf/urls/__init__.py", line 28, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "venv/src/django-grappelli-25x/grappelli/urls.py", line 12, in <module>
    from .views.switch import switch_user
  File "venv/src/django-grappelli-25x/grappelli/views/switch.py", line 18, in <module>
    User = get_user_model()
  File "venv/src/django/django/contrib/auth/__init__.py", line 129, in get_user_model
    return django_apps.get_model(settings.AUTH_USER_MODEL)
  File "venv/src/django/django/apps/registry.py", line 187, in get_model
    self.check_ready()
  File "venv/src/django/django/apps/registry.py", line 119, in check_ready
    raise RuntimeError("App registry isn't ready yet.")
RuntimeError: App registry isn't ready yet.
@sehmaschine
Copy link
Owner

it doesn´t make sense to patch against master, if it´s a backwards-incompatible change. this is only related to django 1.7, right?

@blueyed
Copy link
Contributor Author

blueyed commented Mar 23, 2014

Yes, it's only relevant for Django 1.7.

I've thought that master would get branched for 1.7 later?

@sehmaschine
Copy link
Owner

@blueyed You're right – I assumed you wanna merge this right now.

@sehmaschine sehmaschine self-assigned this Mar 24, 2014
@blueyed
Copy link
Contributor Author

blueyed commented Mar 24, 2014

No, but I wonder what Django version the master is targeting then, since there is the stable branch for Django 1.6 already?
btw: I would appreciate it being merged, instead of cherry-picked (like in #450); I just had to verify that it got merged actually).

@sehmaschine
Copy link
Owner

master is always targeting the latest stable release (see docs). there are actually 2 stable branches for different django-versions – IMO, it´s hard to follow another one (and just too much effort for us).

besides, merging is always the better option ... but that probably requires another patch once we target django 1.7.

the plan is to release another version with bugfixes and then start working on 1.7 (in about 3-4 weeks hopefully).

@sehmaschine
Copy link
Owner

@blueyed I'm not able to reproduce this error ...

@blueyed
Copy link
Contributor Author

blueyed commented Apr 14, 2014

@sehmaschine
Is grappelli/urls.py not being loaded in your case?
Are you using the new app loading mechanism for Grappelli?
Do you have the default AUTH_USER_MODEL setting?

@sehmaschine
Copy link
Owner

@blueyed urls are being loaded. but I don´t understand how your next 2 questions are related to the topic ... in other words: what do I need to do in order to reproduce this error? do I need to use a custom user model?

@sehmaschine
Copy link
Owner

still not able to reproduce this!

@sehmaschine
Copy link
Owner

closing this since I've never been able to reproduce it ... please reopen with additional details if this error still exists.

@blueyed
Copy link
Contributor Author

blueyed commented Mar 12, 2015

do I need to use a custom user model?

Yes. And then this also needs django-debug-toolbar's automatic patching to trigger it.

I am not currently affected by this though anymore, because DEBUG_TOOLBAR_PATCH_SETTINGS = False is also used for other reasons (ref: jazzband/django-debug-toolbar#521).

From the traceback:

File "venv/local/lib/python2.7/site-packages/debug_toolbar/models.py", line 63, in <module>
  patch_root_urlconf()
...
File "venv/src/django-grappelli-25x/grappelli/views/switch.py", line 18, in <module>
  User = get_user_model()
File "venv/src/django/django/contrib/auth/__init__.py", line 129, in get_user_model
  return django_apps.get_model(settings.AUTH_USER_MODEL)
File "venv/src/django/django/apps/registry.py", line 187, in get_model
  self.check_ready()
File "venv/src/django/django/apps/registry.py", line 119, in check_ready
  raise RuntimeError("App registry isn't ready yet.")

It's OK to leave this closed for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants