Generic detail view PostDetailView must be called with either an object pk or a slug.解决
Django 使用DetailView有这个问题,url,和模板统一调用模型时,用pk,而不是id
如果不是用DetailView,只是简单的视图,则用pk 或者id都可以.
urls.py:
url(r'^detail/(?P<pk>\d+)',PostDetailView.as_view(),name='detail'),
模板调用部分:
<a href="{% url 'blogs:detail' post.id %}">{{ post.title }}</a>