AppRegistryNotReady: The translation infrastructure cannot be initialized

前提是你 提交于 2019-12-03 09:59:48

I faced the same error. Following worked for me. In your wsgi file change the last line to :

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

This have been changed fro django 1.6 to newer version. Here is the post that helped to deploy the django app.

If you want to use Nginx as webserver to deploy django app follow this post.

@hellsgate solution worked for me.

Specifically from the link referenced by @hellsgate, I changed:

module = django.core.handlers.wsgi:WSGIHandler()

to

module = django.core.wsgi:get_wsgi_application()

in my vassals.ini file

jojo

This is an answer for the less clever ones (like me): Be sure to check the obvious: The error message says: ... Check that you don't make non-lazy gettext calls at import time. So, if you use django's translation in the verbose_name of a model field or on any other part that is evaluated at import time, you need to use the *_lazy version. If not, you'll end up with the error the OP had.

I basically had:

from django.db import models
from django.utils.translation import gettext as _
import datetime
# other things

class myModle(models.Model):
    date = models.DateField(_('Date'), default=datetime.date.today)
    # other defs. and things

And got the same error as the OP, but my wsgi config was fine.

All I had to do was replacing gettext with gettext_lazy (or ugettext with ugettext_lazy) and everything was fine.

This appears to be the same as this incorrectly reported bug - https://code.djangoproject.com/ticket/23146.

I came across this as well and the fix suggested in that link worked out for me. The update needs to be made in your wsgi.py file. If you aren't sure how to make the change, post 'wsgi.py' for me to have look at

You might be missing setting up path to your application. Check this out my wsgi file. You will find more accurate documentation here https://joshcarllewis.com/articles/getting-started-with-django . I hope it will resolve your problem.

import os, sys

sys.path.append('D:/django/mysite')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

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

You can see what version of "Django" you have installed with:

$python -c 'import django; print (django.get_version ())'

and see that version uses the project "requeriments.txt". If it is not the same version, you have to uninstall "Django" and install the version set to "requeriments.txt".

If you use "virtual environment", may thou standest wrong "virtual environment" and you installed it a new version of django. for example:

In your "requeriments.txt" put Django == 1.6.1

$python -c 'import django; print(django.get_version())' 
1.7.4 
$sudo pip uninstall Django 
$sudo pip install Django==1.6.1

Same answer as @hellsgate and @shawn. I had to replace

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

by

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!