解決したいこと
Djangoでデプロイするとデプロイ前は問題がないのにデプロイ後にエラーが発生してしまいます。
テンプレート内の問題でなくsettings.pyで{% load i18n %}を読み込めていないなどの問題であると思います。
テンプレートはDjango公式のテンプレート(change_list.html)を使用しています。
発生しているエラー
Invalid block tag on line32:'translate', expected 'endblock'. Did you forget to register or load this tag?
settings.py
1from pathlib import Path 2 3import os 4 5# Build paths inside the project like this: BASE_DIR / 'subdir'. 6BASE_DIR = Path(__file__).resolve().parent.parent 7 8 9# Quick-start development settings - unsuitable for production 10# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/ 11 12# SECURITY WARNING: keep the secret key used in production secret! 13SECRET_KEY = 'django-insecure-3tvj=1%mg7q^e8gre&@b#%a^x59=_w&z!pr+_4ravh@v8y#eo+' 14 15# SECURITY WARNING: don't run with debug turned on in production! 16DEBUG = True 17 18ALLOWED_HOSTS = ['*'] 19 20 21# Application definition 22 23INSTALLED_APPS = [ 24 'polls.apps.PollsConfig', 25 26 'django.contrib.admin', 27 'django.contrib.auth', 28 'django.contrib.contenttypes', 29 'django.contrib.sessions', 30 'django.contrib.messages', 31 'django.contrib.staticfiles', 32] 33 34MIDDLEWARE = [ 35 'django.middleware.security.SecurityMiddleware', 36 'django.contrib.sessions.middleware.SessionMiddleware', 37 'django.middleware.locale.LocaleMiddleware', 38 'django.middleware.common.CommonMiddleware', 39 'django.middleware.csrf.CsrfViewMiddleware', 40 'django.contrib.auth.middleware.AuthenticationMiddleware', 41 'django.contrib.messages.middleware.MessageMiddleware', 42 'django.middleware.clickjacking.XFrameOptionsMiddleware', 43] 44 45ROOT_URLCONF = 'mysite.urls' 46 47TEMPLATES = [ 48 { 49 'BACKEND': 'django.template.backends.django.DjangoTemplates', 50 'DIRS': [], 51 'APP_DIRS': True, 52 'OPTIONS': { 53 'context_processors': [ 54 'django.template.context_processors.debug', 55 'django.template.context_processors.request', 56 'django.contrib.auth.context_processors.auth', 57 'django.contrib.messages.context_processors.messages', 58 ], 59 }, 60 }, 61] 62 63WSGI_APPLICATION = 'mysite.wsgi.application' 64 65 66# Database 67# https://docs.djangoproject.com/en/4.0/ref/settings/#databases 68 69DATABASES = { 70 'default': { 71 'ENGINE': 'django.db.backends.sqlite3', 72 'NAME': str(BASE_DIR / 'db.sqlite3'), 73 } 74} 75 76 77# Password validation 78# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators 79 80AUTH_PASSWORD_VALIDATORS = [ 81 { 82 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 83 }, 84 { 85 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 86 }, 87 { 88 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 89 }, 90 { 91 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 92 }, 93] 94 95 96# Internationalization 97# https://docs.djangoproject.com/en/4.0/topics/i18n/ 98 99LANGUAGE_CODE = 'ja' 100 101TIME_ZONE = 'Asia/Tokyo' 102 103USE_I18N = True 104 105USE_TZ = True 106 107from django.utils.translation import gettext_lazy as _ 108LANGUAGES = [ 109 ('ja', _('Japanese')), 110 ('en', _('English')), 111] 112 113LOCALE_PATHS = ( 114 os.path.join(BASE_DIR, 'locale'), 115) 116 117# Static files (CSS, JavaScript, Images) 118# https://docs.djangoproject.com/en/4.0/howto/static-files/ 119 120STATIC_URL = '/static/' 121 122STATIC_ROOT = os.path.join(BASE_DIR, 'static') 123 124# Default primary key field type 125# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field 126 127DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' 128
あなたの回答
tips
プレビュー