所以我正在制作电视节目的情节跟踪器,目前正在制作“添加节目”形式。当我去localhost:8000 / add时,它说没有找到。我可能做错了什么?
views.py
class ShowCreate(CreateView):
model = Show
fields = ['title', 'description', 'episode', 'season']
的index.html
<a href="{% url 'show:show-add' %}">Add</a>
urls.py
url(r'^add/$', views.ShowCreate.as_view(), name='show-add'),
show_form.html
{% extends 'show/base.html' %}
{% block title %}Add Show{% endblock %}
{% block content %}
<form action="" method="post">
{% csrf_token %}
<h1>Add show</h1>
{% include 'show/form-template.html' %}
<button>Submit</button>
</form>
{% endblock %}
form_template.html
{% for field in form %}
<div class="form">
<h3>{{field.label_tag}}</h3>
<div class="field">{{field}}</div>
</div><!--form-->
{% endfor %}
这是urlpatterns中的所有内容
urlpatterns = [
# index
url(r'^$', views.IndexView.as_view(), name='index'),
# show detail
url(r'^(?P<show>[\w.@+-]+)/$', views.ShowDetail.as_view(), name='show-detail'),
# form to add show
url(r'^add/$', views.ShowCreate.as_view(), name='show-add'),
# delete show
# signup
# login
# logout
]
错误讯息:
Page not found (404)
Request Method: GET
Request URL: http://localhost:8000/add/
Raised by: show.views.ShowDetail
main urls.py
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^', include('show.urls')),
]