Django DetailView 发生错误?

Django DetailView occurs an error?

我在 Django 1.9.5 中实现了非常简单的 DetailView:

class PostDetailView(DetailView):
    Model = Post
    template_name = "post/detail.html"

urls.py

from django.conf.urls import url

from chacha_dabang.views import *

urlpatterns = [
    url(r'^$', PostListView.as_view(), name="post_list"),
    url(r'^new/$', post_new, name="post_new"),
    url(r'^(?P<pk>\d+)/$', PostDetailView.as_view(), name="post_detail"),
    url(r'^(?P<pk>\d+)/edit$', post_edit, name="post_edit"),
    url(r'^(?P<pk>\d+)/delete$', post_delete, name="post_delete"),

    url(r'^(?P<pk>\d+)/comment/new/$', comment_new, name="comment_new"),
    url(r'^(?P<pk>\d+)/comment/(?P<comment_pk>\d+)/edit$', comment_edit, name="comment_edit"),
]

错误:

我不知道为什么它说我必须覆盖 query_set()。 (据我所知,DetailView根据pk自动设置查询)

如果我像下面那样使用 Function Based View

def post_detail(request, pk):
    post = Post.objects.get(pk=pk)
    return render(
        request,
        'post/detail.html',
        {
            'post': post,
        }
    )

它完全可以正常工作。需要你的帮助。

您大写了 model。不是Model,应该是model