德扬戈。在本地工作但不在pythonanywhere.com上工作的模板
当我在本地运行django时,我在django中有一个工作项目,但当我在pythonanywhere.com上运行它时,我就没有了。我得到了错误模板Doesnotexist 如何让它在pythonanywhere.com上运行 我是否必须在代码或Pythonywhere web应用程序设置中执行某些操作 谢谢 我的代码: 设置.py德扬戈。在本地工作但不在pythonanywhere.com上工作的模板,python,django,pythonanywhere,Python,Django,Pythonanywhere,当我在本地运行django时,我在django中有一个工作项目,但当我在pythonanywhere.com上运行它时,我就没有了。我得到了错误模板Doesnotexist 如何让它在pythonanywhere.com上运行 我是否必须在代码或Pythonywhere web应用程序设置中执行某些操作 谢谢 我的代码: 设置.py import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DEBUG = True
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'assets'),
)
您不应该在
模板
设置中使用相对目录'templates'
。尝试将DIRS
更改为:
'DIRS': [os.path.join(BASE_DIR, 'templates')],