我差一点就扔掉了模板。它不适合我。始终在默认目录中查找模板:
/Library/Python/2.7/site-packages/allauth/templates/account
我几乎尝试了所有我发现的东西: https://stackoverflow.com/a/18811664/3348531 https://stackoverflow.com/a/40065009/3348531
我的目录结构:
myproject
myproject
myapp
templates
accounts
login.html
...
但我也尝试:
myproject
myproject
myapp
templates
myapp
accounts
login.html
...
没什么可行的
--urls.py
urlpatterns = [
url(r'^accounts/', include('allauth.urls')),
...
--settings.py
INSTALLED_APPS = [
'formimmapp.apps.FormimmappConfig',
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'formtools',
'crispy_forms',
]
TEMPLATE_DIRS = (os.path.join(PROJECT_DIR, 'templates'),)
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
# 'DIRS': [os.path.join(BASE_DIR,'templates')],
'DIRS': [os.path.join(PROJECT_DIR, 'templates')],
# 'DIRS': [],
'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',
],
},
},
Django版
1.10.1
答案 0 :(得分:2)
一个容易犯的错误。很多人将这个添加到他们的urls.py的以下行,并认为模板应该进入名为accounts
的文件夹 url(r'^accounts/', include('allauth.urls')),
但事实并非如此,这只是登录网址的网址映射。应用名称来自
'allauth',
'allauth.account',
myproject
myproject
myapp
templates
myapp
accounts
将其重命名为帐户,您将没事