I got a raised exception:
{{{
Traceback (most recent call last):
File "/var/www/project.com/project/polls/tests.py", line 97, in
test_index_view_with_two_past_questions
['<Question: Past question 2.>', '<Question: Past question 1.>']
File "/usr/local/lib/python3.4/dist-packages/django/test/testcases.py",
line 853, in assertQuerysetEqual
raise ValueError("Trying to compare non-ordered queryset "
ValueError: Trying to compare non-ordered queryset against more than one
ordered values
}}}
I found the error to be resolved using list():
{{{
def test_index_view_with_two_past_questions(self):
"""
The questions index page may display multiple questions.
"""
create_question(question_text="Past question 1.", days=-30)
create_question(question_text="Past question 2.", days=-5)
response = self.client.get(reverse('polls:index'))
self.assertQuerysetEqual(
list(response.context['latest_question_list']),
list(['<Question: Past question 2.>', '<Question: Past
question 1.>'])
)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/23654>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
Hi,
Are you using the same view as the one defined in part 4 [1]?
Those define the queryset as `Question.objects.order_by('-pub_date')[:5]`
so that error message should not get triggered.
Thanks.
[1] https://docs.djangoproject.com/en/1.7/intro/tutorial04/#amend-views
--
Ticket URL: <https://code.djangoproject.com/ticket/23654#comment:1>
* status: new => closed
* resolution: => invalid
Comment:
That resolved it.
--
Ticket URL: <https://code.djangoproject.com/ticket/23654#comment:2>