I\'ve followed django tutorial and arrived at tutorial05.
I tried to not show empty poll as tutorial says, so I added filter condition like this:
cla
choice__isnull
causes the problem. It leads to join with choice
table (to weed out questions
without choices
), that is something like this:
SELECT question.*
FROM question
JOIN choice
ON question.id = choice.question_id
WHERE question.pub_date < NOW()
You can inspect query
attribute of QuerySet
to be sure. So if you have one question
with two choices
, you will get that question
two times. You need to use distinct() method in this case: queryset.distinct()
.