AppRegistryNotReady:翻译基础设施无法初始化

2024-04-27

当我尝试访问我的应用程序时,出现以下错误:

AppRegistryNotReady:翻译基础设施无法 在应用程序注册表准备好之前初始化。检查你是否没有 在导入时进行非惰性 gettext 调用

这是我的 wsgi.py 文件:

"""                                                                                                                                                                                     
WSGI config for Projectizer project.                                                                                                                                                    
                                                                                                                                                                                        
It exposes the WSGI callable as a module-level variable named ``application``.                                                                                                          
                                                                                                                                                                                        
For more information on this file, see                                                                                                                                                  
https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/                                                                                                                            
"""

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Projectizer.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

这是堆栈跟踪。

mod_wsgi (pid=28928): Exception occurred processing WSGI script '/var/www/projectizer/apache/django.wsgi'.

Traceback (most recent call last):

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 187, in __call__

    response = self.get_response(request)

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 199, in get_response

    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 236, in handle_uncaught_exception

    return debug.technical_500_response(request, *exc_info)

File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 91, in technical_500_response

    html = reporter.get_traceback_html()

File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 350, in get_traceback_html

    return t.render(c)

File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 148, in render

    return self._render(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 142, in _render

    return self.nodelist.render(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 844, in render

    bit = self.render_node(node, context)

File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 80, in render_node

    return node.render(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 90, in render

    output = self.filter_expression.resolve(context)

File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 624, in resolve

    new_obj = func(obj, *arg_vals)

File "/usr/local/lib/python2.7/dist-packages/django/template/defaultfilters.py", line 769, in date

    return format(value, arg)

File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 343, in format

    return df.format(format_string)

File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 35, in format

    pieces.append(force_text(getattr(self, piece)()))

File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 268, in r

    return self.format('D, j M Y H:i:s O')

File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 35, in format

    pieces.append(force_text(getattr(self, piece)()))

File "/usr/local/lib/python2.7/dist-packages/django/utils/encoding.py", line 85, in force_text

    s = six.text_type(s)

File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 144, in __text_cast

    return func(*self.__args, **self.__kw)

File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py", line 83, in ugettext

    return _trans.ugettext(message)

File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 325, in ugettext

    return do_translate(message, 'ugettext')

File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 306, in do_translate

    _default = translation(settings.LANGUAGE_CODE)

File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 209, in translation

    default_translation = _fetch(settings.LANGUAGE_CODE)

File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 189, in _fetch

    "The translation infrastructure cannot be initialized before the "

AppRegistryNotReady: 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.

我遇到了同样的错误。以下对我有用。 在您的 wsgi 文件中将最后一行更改为:

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

自 Django 1.6 到更新版本以来,这一点已发生变化。Here http://jee-appy.blogspot.com/2015/04/deploy-django-project-on-apache-using.html是帮助部署 django 应用程序的帖子。

如果你想使用 Nginx 作为网络服务器来部署 django 应用程序,请遵循this http://jee-appy.blogspot.com/2017/01/deply-django-with-nginx.html post.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

AppRegistryNotReady:翻译基础设施无法初始化 的相关文章

随机推荐