Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

p162 IndexView部分代码有问题 #38

Open
github-yao-tong opened this issue Apr 22, 2020 · 1 comment
Open

p162 IndexView部分代码有问题 #38

github-yao-tong opened this issue Apr 22, 2020 · 1 comment

Comments

@github-yao-tong
Copy link

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 就好了。

@MaoningGuan
Copy link

我照着上面的代码写,没有问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants