0
我一直在試圖使用Django創建一個簡單的Web應用程序,但不斷收到錯誤的TemplateDoesNotExist錯誤!模板不存在
我的網址
from django.conf.urls import url, include
from django.contrib import admin
from buisnesscard import views
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^login/', views.login, name='login'),
]
我views.py
from django.shortcuts import render
from django.template.loader import get_template
def login(request):
return render(request, get_template('form.html'), {})
而不是使用get_template我甚至試過
from django.shortcuts import render
def login(request):
return render(request, 'buisnesscard/templates/buisnesscard/form.html', {})
Settings.py
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',
],
},
},
]
試圖改變目錄到
'DIRS' :[ 'buisnesscard/templates/buisnesscard']
我的HTML文件包含一個簡單的靜態文件,並獲得誤差爲
form.html
Request Method: GET
Request URL: http://127.0.0.1:8000/login/
Django Version: 1.10b1
Exception Type: TemplateDoesNotExist
Exception Value:
form.html
Exception Location: C:\Python27\lib\site-packages\django-1.10b1-py2.7.egg\django\template\loader.py in get_template, line 25
Python Executable: C:\Python27\python.exe
Python Version: 2.7.9
Python Path:
['E:\\Django files\\forms',
'C:\\Python27\\lib\\site-packages\\django-1.10b1-py2.7.egg',
'C:\\Windows\\SYSTEM32\\python27.zip',
'C:\\Python27\\DLLs',
'C:\\Python27\\lib',
'C:\\Python27\\lib\\plat-win',
'C:\\Python27\\lib\\lib-tk',
'C:\\Python27',
'C:\\Python27\\lib\\site-packages']
Server time: Wed, 6 Jul 2016 10:57:11 +0530
目前在Python版本上運行ñ2.7
糾正錯誤仍然給我相同的TemplateDoesNotExist錯誤幫助 –
你是否正確指出了Django實際存在於buisnesscard/templates/buisnesscard/form.html中的文件? –
模板文件夾應爲小寫 –