已在heroku环境中部署了Django项目,并且翻译无法正常工作

时间:2019-05-20 23:25:38

标签: django heroku

182/5000 我在Django的默认翻译中遇到问题,在开发环境中,当在Heroku上完成部署无法正常工作时,它可以正常工作。这是我执行的步骤:

我的环境网址: https://portalbigidea.herokuapp.com/

在我的heroku环境中,这是django .mo,如下所示:

您在Heroku环境中设置了以下buildpack:
heroku buildpacks:set https://github.com/piotras/heroku-buildpack-gettext.git

$ heroku run ls locale / en / LC_MESSAGES

在portalbigidea上运行ls locale / en / LC_MESSAGES ...,运行3990(免费)
django.mo django.po
8258(免费)在portalbigidea上运行ls locale / pt_BR / LC_MESSAGES ...,运行。
django.mo django.po

settings / base.py

ALLOWED_HOSTS = [“本地主机”,“ 127.0.0.1”,“。herokuapp.com”]

INSTALLED_APPS =
    'django_adminlte',
    'django_adminlte_theme',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'whitenoise.runserver_nostatic',
    'django.contrib.staticfiles',
]

MIDDLEWARE = [
    “ django.middleware.security.SecurityMiddleware”,
'whitenoise.middleware.WhiteNoiseMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

DATABASES = {'默认':dj_database_url.config(conn_max_age = 500,ssl_require = True)}

CORS_REPLACE_HTTPS_REFERER =真
HOST_SCHEME =“ https://”
SECURE_PROXY_SSL_HEADER =(“ HTTP_X_FORWARDED_PROTO”,'https')
SECURE_SSL_REDIRECT =真
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE =真
SECURE_HSTS_INCLUDE_SUBDOMAINS =真
SECURE_HSTS_SECONDS = 1000000
SECURE_FRAME_DENY = True

STATIC_ROOT = os.path.join(BASE_DIR,“静态文件”)

STATICFILES_DIRS = [os.path.join(BASE_DIR,“静态文件”)]

STATICFILES_STORAGE = whitenoise.storage.CompressedManifestStaticFilesStorage'

django.utils.translation中的

以_

导入ugettext_lazy

LOCALE_PATHS =(BASE_DIR +'\ locale',)

USE_I18N = True
USE_L10N = True
USE_TZ = True
TIME_ZONE ='UTC'

LANGUAGE_CODE ='pt-br'

LANGUAGES =(
    ('en',_('English')),
    ('pt-br',_('巴西葡萄牙语')),

我很感谢所提供的所有帮助,如果我找到针对这种情况的解决方案,请在下面的线程中告知。

在本地环境(dev)中的预期和预期响应:
enter image description here

enter image description here

在Herokul云(产品)的Heroku环境中收到的响应:
enter image description here

0 个答案:

没有答案