[Django] #33332: Writing your first Django app, part 5 - error please help me.

8 views
Skip to first unread message

Django

unread,
Nov 30, 2021, 11:49:02 AM11/30/21
to django-...@googlegroups.com
#33332: Writing your first Django app, part 5 - error please help me.
---------------------------------------------+------------------------
Reporter: seoyule | Owner: nobody
Type: Uncategorized | Status: new
Component: Testing framework | Version: 3.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------------+------------------------
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.context['latest_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.>']
? - -

+ [<Question: Past question.>]

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

Thank you so much

--
Ticket URL: <https://code.djangoproject.com/ticket/33332>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 30, 2021, 1:44:41 PM11/30/21
to django-...@googlegroups.com
#33332: Writing your first Django app, part 5 - error please help me.
-----------------------------------+--------------------------------------

Reporter: seoyule | Owner: nobody
Type: Uncategorized | Status: new
Component: Testing framework | Version: 3.2
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by Carlton Gibson):

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.)

--
Ticket URL: <https://code.djangoproject.com/ticket/33332#comment:1>

Django

unread,
Nov 30, 2021, 1:44:53 PM11/30/21
to django-...@googlegroups.com
#33332: Writing your first Django app, part 5 - error please help me.
-----------------------------------+--------------------------------------
Reporter: seoyule | Owner: nobody
Type: Uncategorized | Status: closed

Component: Testing framework | Version: 3.2
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by Carlton Gibson):

* status: new => closed
* resolution: => invalid


--
Ticket URL: <https://code.djangoproject.com/ticket/33332#comment:2>

Django

unread,
Nov 30, 2021, 2:00:35 PM11/30/21
to django-...@googlegroups.com
#33332: Writing your first Django app, part 5 - error please help me.
-----------------------------------+--------------------------------------
Reporter: seoyule | Owner: nobody
Type: Uncategorized | Status: closed

Component: Testing framework | Version: 3.2
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by Mariusz Felisiak):

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

--
Ticket URL: <https://code.djangoproject.com/ticket/33332#comment:3>

Reply all
Reply to author
Forward
0 new messages