#25800 closed Uncategorized (invalid)
IIS ISAPI request throws AppRegistryNotReady: Apps aren't loaded yet.
Reported by: | Ola | Owned by: | nobody |
---|---|---|---|
Component: | HTTP handling | Version: | 1.8 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
After deep investigation of why IIS throws A server error occurred. Please contact the administrator.` looks like
url(r'^render_template/', views.render_template, name="render_template"), def render_template(request): try: logger.error("test template iis") context = {'foo': 'template'} t = template_loader.get_template('webclient/test.html') c = RequestContext(request, context) return HttpResponse(t.render(c)) except: logger.error(traceback.format_exc()) return HttpResponse(traceback.format_exc())
throws
Traceback (most recent call last): File "C:\OMERO.server\lib\python\omeroweb\webclient\views.py", line 36, in render_template t = template_loader.get_template('webclient/test.html') File "C:\Python27\lib\site-packages\django\template\loader.py", line 35, in get_template return engine.get_template(template_name, dirs) File "C:\Python27\lib\site-packages\django\template\backends\django.py", line 30, in get_template return Template(self.engine.get_template(template_name, dirs)) File "C:\Python27\lib\site-packages\django\template\engine.py", line 167, in get_template template, origin = self.find_template(template_name, dirs) File "C:\Python27\lib\site-packages\django\template\engine.py", line 141, in find_template source, display_name = loader(name, dirs) File "C:\Python27\lib\site-packages\django\template\loaders\base.py", line 13, in __call__ return self.load_template(template_name, template_dirs) File "C:\Python27\lib\site-packages\django\template\loaders\base.py", line 17, in load_template template_name, template_dirs) File "C:\Python27\lib\site-packages\django\template\loaders\app_directories.py", line 36, in load_template_source for filepath in self.get_template_sources(template_name, template_dirs): File "C:\Python27\lib\site-packages\django\template\loaders\app_directories.py", line 26, in get_template_sources template_dirs = get_app_template_dirs('templates') File "C:\Python27\lib\site-packages\django\utils\lru_cache.py", line 125, in wrapper result = user_function(*args, **kwds) File "C:\Python27\lib\site-packages\django\template\utils.py", line 122, in get_app_template_dirs for app_config in apps.get_app_configs(): File "C:\Python27\lib\site-packages\django\apps\registry.py", line 137, in get_app_configs self.check_apps_ready() File "C:\Python27\lib\site-packages\django\apps\registry.py", line 124, in check_apps_ready raise AppRegistryNotReady("Apps aren't loaded yet.") AppRegistryNotReady: Apps aren't loaded yet.
Note above error appear only with IIS response rendering template, plain HttpResponse("string") or JsonResponse, HttpResponseRedirect works as expected.
Change History (5)
comment:1 by , 9 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 9 years ago
To expand on what Tim just said -- your deployment probably bypasses the official APIs for running Django on a WSGI server. As a consequence, in Django ≥ 1.7, django.setup()
isn't called and you're seeing this exception.
comment:3 by , 9 years ago
I went one step forward and now got
Traceback (most recent call last): File "c:\OMERO.server\lib\python\omeroweb\webclient\views.py", line 197, in login form = LoginForm(data=request.POST.copy()) File "c:\OMERO.server\lib\python\omeroweb\webadmin\forms.py", line 52, in __init__ super(LoginForm, self).__init__(*args, **kwargs) File "c:\OMERO.server\lib\python\omeroweb\custom_forms.py", line 35, in __init__ super(NonASCIIForm, self).__init__(*args, **kwargs) File "C:\Python27\lib\site-packages\django\forms\forms.py", line 129, in __init__ self.label_suffix = label_suffix if label_suffix is not None else _(':') File "C:\Python27\lib\site-packages\django\utils\translation\__init__.py", line 84, in ugettext return _trans.ugettext(message) File "C:\Python27\lib\site-packages\django\utils\translation\trans_real.py", line 327, in ugettext return do_translate(message, 'ugettext') File "C:\Python27\lib\site-packages\django\utils\translation\trans_real.py", line 304, in do_translate _default = _default or translation(settings.LANGUAGE_CODE) File "C:\Python27\lib\site-packages\django\utils\translation\trans_real.py", line 206, in translation _translations[language] = DjangoTranslation(language) File "C:\Python27\lib\site-packages\django\utils\translation\trans_real.py", line 116, in __init__ self._add_installed_apps_translations() File "C:\Python27\lib\site-packages\django\utils\translation\trans_real.py", line 164, in _add_installed_apps_translations "The translation infrastructure cannot be initialized before the " \nAppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import time.
It looks very simmilar to https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/django-users/jk_BrQY_S5c/1cWN6KF9qNIJ although I use wsgi_isapi rather then fastcgi. Calling setup like https://github.com/aleksandra-tarkowska/openmicroscopy/blob/iss_deploy_improvement/components/tools/OmeroPy/src/omero_web_iis.py cause IIS error
follow-up: 5 comment:4 by , 9 years ago
and I am using from django.utils.translation import ugettext_lazy as _
comment:5 by , 9 years ago
Replying to atarkowska:
and I am using from django.utils.translation import ugettext_lazy as _
The traceback you quote claims otherwise.
Also, it has been mentioned to you that Trac is not a support channel. The place to ask "is this a bug" questions, when you are not sure what is wrong, is the django-users mailing list or the #django IRC channel. This ticket has been closed, and you should expect no more answers here.
Please see the Troubleshooting guide which describes reasons why you would hit
AppRegistryNotReady
. As with #25607, please use our support channels at TicketClosingReasons/UseSupportChannels as the report doesn't demonstrate that Django is at fault. Thanks!