django 1.9和registration/login.html [英] django 1.9 and registration/login.html

查看:271
本文介绍了django 1.9和registration/login.html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究django 1.9项目.

I'm working on a django 1.9 project.

使用Django 1.7.7,登录功能可以正常工作,但是现在我一直都在:registration/login.html : Template Does Not Exist

With Django 1.7.7, login functionnalities was working, but now all the time I have : registration/login.html : Template Does Not Exist

模板login.html,logout.html位于"webgui/template/registration/"中,但我没有对其进行修改.

The templates login.html, logout.html are present in 'webgui/template/registration/' and I didn't modified them.

这是我的一些settings.py:

Here some of my settings.py :

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'webgui',
]

MIDDLEWARE_CLASSES = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'project.urls'

TEMPLATES = [
{
    'BACKEND': 'django.template.backends.django.DjangoTemplates',
    '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',
        ],
    },
},
]

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.sqlite3',
    'NAME': os.path.join(BASE_DIR, 'NCIS.db'),
}
}

STATIC_URL = '/static/'
LOGIN_REDIRECT_URL = '/login/'

LOGOUT_URL = '/logout/'


DIRS = (
    join(BASE_DIR, 'webgui/template/registration'),
    join(BASE_DIR, 'webgui/template/')
)

还有我的urls.py:

from django.conf.urls import url
from django.contrib import admin
from django.contrib.auth.views import login, logout
import webgui.views

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^$', login, name='login.html'),
    url(r'^login/$', login, name='login.html'),
    url(r'^logout/$', logout, name='logout.html'),

    url(r'^homepage/$', webgui.views.homepage),
    url(r'^addproject/$', webgui.views.addproject)
]

怎么了?我检查了Django文档,但这是默认的行为.

What's wrong? I checked the Django docs, but that's the default behaviour.

推荐答案

尝试将模板目录路径放在TEMPLATES设置内的DIRS列表中. (无论如何,您的模板文件夹名称应为templates而不是template.)

Try to put your template dirs paths in DIRS list inside TEMPLATES setting. (Anyway, your template folder name should be templates not template.)

TEMPLATES = [
{
    'BACKEND': 'django.template.backends.django.DjangoTemplates',
    'DIRS': [join(BASE_DIR, 'webgui/template/registration'),join(BASE_DIR, 'webgui/template/')],
    '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.9和registration/login.html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆