我有以下看法:
class IndexView(generic.ListView):
template_name = "polls/index.html"
context_object_name = "latest_poll_list"
def get_queryset(self):
"""
Return the last five active published polls with at least
two choices.
"""
return Poll.objects.filter(pub_date__lte=timezone.now(),
is_active__exact=True,
).order_by('-pub_date')[:5]
而且我只想发布有两个或更多选择的民意调查。我尝试了许多变体,但都无法正常工作。
我怎样才能巧妙地实现这一点?