我之前曾经问过这个问题,但是我已经尝试了所有的东西,仍然无法让它发挥作用。
我在/ Users / username / Documents / python / skillshare / static / templates
中制作了一个模板文件这是我的settings.py:
import os
BASE_DIR ='/Users/chrismeek/Documents/python/skillshare/mvp_landing'
SECRET_KEY = 'w+u&5h%=iapf9cdj8d=9!!wppny54jc7a=_$ip2s6!!e!=w65^'
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = []
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'signups',
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'mvp_landing.urls'
WSGI_APPLICATION = 'mvp_landing.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/static/'
TEMPLATE_DIR = (
'/Users/chrismeek/Documents/python/skillshare/static/templates'
)
然后我收到此错误
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
Using loader django.template.loaders.app_directories.Loader:
/Users/chrismeek/Documents/Python/skillshare/lib/python2.7/site-packages/django/contrib/admin/templates/signup.html (File does not exist)
/Users/chrismeek/Documents/Python/skillshare/lib/python2.7/site- packages/django/contrib/auth/templates/signup.html (File does not exist)
如果我将模板文件放在寻找它们的位置,但希望更改它们,因为它看起来很麻烦。
答案 0 :(得分:2)
该设置名为TEMPLATE_DIRS
,而非TEMPLATE_DIR
。它应该包含Django搜索模板的位置列表:
TEMPLATE_DIRS = (
'/Users/chrismeek/Documents/python/skillshare/static/templates',
)