我是 django 的新手,我收到一条错误消息,提示使用 portal.urls 中定义的 URLconf,Django 按以下顺序尝试了这些 URL 模式:^event/ ^$ [name='index'] ^event/ ^pg1$ [ name='pg1'] ^admin/ 当前 URL,event/event/pg1.html,与其中任何一个都不匹配。
我的 views.py 文件是
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response,render
from event.models import Login,Page1
def index(request):
return render_to_response("event/index.html")
def pg1(request):
return render_to_response("event/pg1.html")
我的 pg1.html
<html>
<body>
<form>
{%csrf_token%}
Branch
</br>
<select name="Branch">
<option value="CSE">CSE</option>
<option value="CSD">CSD</option>
<option value="ECE">ECE</option>
</select>
</br>
</br>
Event Name: <input type="text" name="eventname"><br>
</br>
Test Date :<input type="date" name="test_date"><br>
Test Time:<input type="time" name="test_time"><br>
<input type="button" value="submit">
</form>
</body>
</html>
我的 index.html 文件
<!DOCTYPE html>
<html>
<body>
<form name="input" action="/event/pg1.html" method="post">
{%csrf_token%}
Username: <input type="text" name="user"><br>
Password: <input type="password" name="pwd"><br>
<input type="submit" Value="submit">
</form>
</body>
</html>
我的 urls.py 文件:
from django.conf.urls import patterns, url, include
from event import views
urlpatterns = patterns('',
url(r'^$', views.index, name='index'),
url(r'^pg1$', views.pg1, name='pg1'),
)