Skip to content Skip to sidebar Skip to footer

Adding Extra Filter To Polls Urls.py Causes Tests To Fail

Following the tutorial at djangoproject, I have tried to have urls.py filter out the polls with no choices with the urlpattern below. urlpatterns = patterns('', url(r'^$',

Solution 1:

I think the problem is, that on the test, you're creating a brand new poll, without any choices yet. And in the detail-view you're filtering this polls out. So it's returning nothing, and so the test fails.

You could additionally create some choices for the poll you just created on the past_test so this polls pass the filtering.

Something like:

...
past_poll = create_poll(question='Past Poll.', days=-5)
past_poll.choice_set.create(choice_text='Choice 1', votes=0)
past_poll.choice_set.create(choice_text='Choice 2', votes=0)
...

Post a Comment for "Adding Extra Filter To Polls Urls.py Causes Tests To Fail"