typeidea
typeidea copied to clipboard
p162 IndexView部分代码有问题
class IndexView(CommonViewMixin, ListView):
queryset = Post.latest_posts()
paginate_by = 5
context_object_name = 'post_list'
template_name = 'blog/list.html'
这样写会报错: django.core.exceptions.ImproperlyConfigured: IndexView is missing a QuerySet. Define IndexView.model, IndexView.queryset, or override IndexView.get_queryset().
需要加个 model = Post 就好了。
我照着上面的代码写,没有问题。