Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#33332 closed Uncategorized (invalid)

Writing your first Django app, part 5 - error please help me.

Reported by: Seoyule Jo Owned by: nobody
Component: Testing framework Version: 3.2
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi Thank you for the great tutorial.

I'm shadowing this tutorial but keep encountering the following error:
AssertionError: Lists differ: <Question: Past question.>? != [<Question: Past question.>]

Below is the related code

def test_past_question(self):

question = create_question(question_text="Past question.", days=-30)
response = self.client.get(reverse('polls:index'))
self.assertQuerysetEqual(

response.contextlatest_question_list,
[question]

)

And below is the error message.
======================================================================
FAIL: test_past_question (polls.tests.QuestionIndexViewTests)
======================================================================
Traceback (most recent call last):

File "/Users/seoyulejo/projects/mysite3/polls/tests.py", line 50, in test_past_question

self.assertQuerysetEqual(

File "/Users/seoyulejo/venvs/mysite/lib/python3.8/site-packages/django/test/testcases.py", line 1052, in assertQuerysetEqual

return self.assertEqual(list(items), values, msg=msg)

AssertionError: Lists differ: <Question: Past question.> != [<Question: Past question.>]

First differing element 0:
'<Question: Past question.>'
<Question: Past question.>

? - -

+ [<Question: Past question.>]

Could anyone help me find out the reason of the error?

Thank you so much

Change History (3)

comment:1 by Carlton Gibson, 3 years ago

Hi, you'll need to post on one of the support channels, such as the forum: https://forum.djangoproject.com

See TicketClosingReasons/UseSupportChannels.

(It's hard to see from the code posted but it looks like you have a string value rather than the object in your context... — Good luck.)

comment:2 by Carlton Gibson, 3 years ago

Resolution: invalid
Status: newclosed

comment:3 by Mariusz Felisiak, 3 years ago

It looks that you're using docs for a wrong version of Django.

Note: See TracTickets for help on using tickets.
Back to Top