I have done the whole Django tutorial, but I could not understand how to display the website, with the polls only bigger than Poll 0 is. I know that poll.objects.get (pk = 1) .choice_set.count () will return the number of options I have, so I tried filter poll.objects.filter (choice_set.count ()> gt; 0 and it did not work. Can someone please help me? Thank you
This is my actual quercet.
queryset = poll.objects.filter (pub_date__lte = timezone.now) .order_by ('- pub_date') [: 5]
queryset = poll.objects.annotate (count = count ('options')). Filter (pub_date__lte = timezone.now, count__gt = 0) .order_by ('- pub_date') [: 5]
No comments:
Post a Comment