我是 Django 新手,我遇到了 NoReverseMatch 错误。有谁知道我该如何解决这个问题?
异常值:未找到带有参数“()”和关键字参数“{}”的“profile_list.html”的反向。
edit_profile.html
<h1>Add Profile</h1>
<form action="{% url 'questions-new' %}" method="POST">
{% csrf_token %}
<ul>
{{ form.as_ul }}
</ul>
<input type="submit" value="Save" />
</form>
<a href="{% url 'profile-list' %}">back to list</a>
网址.py
from django.conf.urls import patterns, include, url
import questions.views
urlpatterns = patterns('',
url(r'^$', questions.views.ListProfileView.as_view(),
name='profile-list'),
url(r'^new$', questions.views.CreateProfileView.as_view(),
name='questions-new',),
)
视图.py
from django.views.generic import ListView
from questions.models import Profile
from django.core.urlresolvers import reverse
from django.views.generic import CreateView
class ListProfileView(ListView):
model = Profile
template_name = 'profile_list.html'
class CreateProfileView(CreateView):
model = Profile
template_name = 'edit_profile.html'
def get_success_url(self):
return reverse('profile_list.html')