Critical: AppRegistryNotReady due to model import at module level in reviewboard/admin/middleware.py when starting under Django >1.9

17 views
Skip to first unread message

Sai Krishna Reddy

unread,
Jul 21, 2025, 4:24:56 PMJul 21
to Review Board Community
We are experiencing a critical startup failure caused by the reviewboard.admin.middleware module importing models at the module level, which is incompatible with Django 1.9+ (and especially Django 3.x/4.x+). This pattern causes Django’s application registry to not be ready at the point of import, leading to AppRegistryNotReady errors.

Error Details
On startup, we receive the following traceback:

Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.11/site-packages/django/core/handlers/wsgi.py", line 127, in __init__
    self.load_middleware()
  File "/app/.heroku/python/lib/python3.11/site-packages/django/core/handlers/base.py", line 40, in load_middleware
    middleware = import_string(middleware_path)
  File "/app/.heroku/python/lib/python3.11/site-packages/django/utils/module_loading.py", line 17, in import_string
    module = import_module(module_path)
  File "/app/.heroku/python/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/app/.heroku/python/lib/python3.11/site-packages/reviewboard/admin/middleware.py", line 4, in <module>
    from djblets.siteconfig.models import SiteConfiguration
  File "/app/.heroku/python/lib/python3.11/site-packages/djblets/siteconfig/models.py", line 7, in <module>
    from django.contrib.sites.models import Site
  File "/app/.heroku/python/lib/python3.11/site-packages/django/contrib/sites/models.py", line 78, in <module>
    class Site(models.Model):
  File "/app/.heroku/python/lib/python3.11/site-packages/django/db/models/base.py", line 108, in __new__
    app_config = apps.get_containing_app_config(module)
  File "/app/.heroku/python/lib/python3.11/site-packages/django/apps/registry.py", line 136, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

This is triggered by the following import in reviewboard/admin/middleware.py:


from djblets.siteconfig.models import SiteConfiguration
which executes at the module level as soon as Django attempts to import middleware classes from MIDDLEWARE in settings.py.


My versions:
  • Django: 3.2.x
  • Review Board: 5.0.7
  • Djblets:3.3
  • Python: 3.11
  • Deployment: Heroku
Steps to Reproduce
  • Use Django 2.x or newer with Review Board.
  • Add 'reviewboard.admin.middleware.ReviewBoardMiddleware' to your MIDDLEWARE in Django settings.
  • Attempt to start any Django process (runserver, uWSGI, etc.)
  • Observe AppRegistryNotReady exception on startup.

Christian Hammond

unread,
Jul 25, 2025, 6:14:55 PMJul 25
to revie...@googlegroups.com
Hi Sai,

I'm sorry, so much of our support happens on our official support tracker that I don't get to circle back to the community list as often.

Did you figure out what's going on here?

Review Board 5 isn't supported anymore, but checking a standard deployment of 5.0.7 locally, I can't reproduce this. It doesn't sound like the Review Board environment is actually being set up at the proper time. By the time the code path you're hitting is executed, the environment should already be running.

Are you manually adding middleware somewhere, given the Steps to Reproduce? Our list of middleware is in a very specific order and shouldn't be touched or rearranged.

I think we'd need to know a lot more about your environment and how you've installed and configured Review Board to know what's going on here.

Christian

--
Supercharge your Review Board with Power Pack: https://www.reviewboard.org/powerpack/
Want us to host Review Board for you? Check out RBCommons: https://rbcommons.com/
Happy user? Let us know! https://www.reviewboard.org/users/
---
You received this message because you are subscribed to the Google Groups "Review Board Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reviewboard...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/reviewboard/559cd133-1a82-47ef-bb31-93465bd93ae9n%40googlegroups.com.


--
Christian Hammond
President/CEO of Beanbag
Makers of Review Board
Reply all
Reply to author
Forward
0 new messages