[Django] #25508: Add "QuerySet()" to QuerySet.__repr__ to help debugging

17 views
Skip to first unread message

Django

unread,
Oct 5, 2015, 7:05:20 PM10/5/15
to django-...@googlegroups.com
#25508: Add "QuerySet()" to QuerySet.__repr__ to help debugging
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: timgraham
Type: | Status: new
Cleanup/optimization |
Component: Database | Version: master
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
`TransactionTestCase.assertQuerysetEqual` can give errors like
`AssertionError: ['1.8', '1.7', '1.4'] != ['1.8', '1.7', '1.4']` when you
compare a list and a QuerySet. Alex proposed to change the repr of
`QuerySet` to `QuerySet([...])` and the idea received several +1's in
#django-dev.

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

Django

unread,
Oct 5, 2015, 7:09:27 PM10/5/15
to django-...@googlegroups.com
#25508: Add "QuerySet()" to QuerySet.__repr__ to help debugging
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: timgraham
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/5398 PR]

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

Django

unread,
Oct 6, 2015, 3:03:08 AM10/6/15
to django-...@googlegroups.com
#25508: Add "QuerySet()" to QuerySet.__repr__ to help debugging
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: timgraham
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by claudep):

Agreed it's a good idea. However, the docs might have to be updated in
many places, for example in
https://docs.djangoproject.com/en/1.8/topics/db/examples/many_to_many/.
`git grep "\[<"` gives an indication about where docs might need en
update.

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

Django

unread,
Oct 6, 2015, 9:01:06 AM10/6/15
to django-...@googlegroups.com
#25508: Add "QuerySet()" to QuerySet.__repr__ to help debugging
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: timgraham
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by timgraham):

Thanks for pointing that out and providing the grep hint. Docs are now
updated.

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

Django

unread,
Oct 6, 2015, 12:20:47 PM10/6/15
to django-...@googlegroups.com
#25508: Add "QuerySet()" to QuerySet.__repr__ to help debugging
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: timgraham
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by claudep):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/25508#comment:4>

Django

unread,
Oct 6, 2015, 1:01:01 PM10/6/15
to django-...@googlegroups.com
#25508: Add "QuerySet()" to QuerySet.__repr__ to help debugging
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: timgraham
Type: | Status: closed

Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

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


Comment:

In [changeset:"e0837f2cb12de5e95e621d19b186b0da43bcdee2" e0837f2c]:
{{{
#!CommitTicketReference repository=""
revision="e0837f2cb12de5e95e621d19b186b0da43bcdee2"
Fixed #25508 -- Modified QuerySet.__repr__() to disambiguate it from a
list.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25508#comment:5>

Django

unread,
Sep 23, 2025, 10:07:43 AM9/23/25
to django-...@googlegroups.com
#25508: Add "QuerySet()" to QuerySet.__repr__ to help debugging
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Tim
Type: | Graham
Cleanup/optimization | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Jacob Walls <jacobtylerwalls@…>):

In [changeset:"efb96138b4af774c22ae6e949410b45d69960357" efb96138]:
{{{#!CommitTicketReference repository=""
revision="efb96138b4af774c22ae6e949410b45d69960357"
Refs #25508 -- Used QuerySet.__repr__ in
docs/ref/contrib/postgres/search.txt.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25508#comment:6>

Django

unread,
Sep 23, 2025, 10:09:07 AM9/23/25
to django-...@googlegroups.com
#25508: Add "QuerySet()" to QuerySet.__repr__ to help debugging
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Tim
Type: | Graham
Cleanup/optimization | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Jacob Walls <jacobtylerwalls@…>):

In [changeset:"fd94c90526d1709318ea21b9cd56c5ae5b54c443" fd94c90]:
{{{#!CommitTicketReference repository=""
revision="fd94c90526d1709318ea21b9cd56c5ae5b54c443"
[6.0.x] Refs #25508 -- Used QuerySet.__repr__ in
docs/ref/contrib/postgres/search.txt.

Backport of efb96138b4af774c22ae6e949410b45d69960357 from main.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25508#comment:7>

Django

unread,
Sep 23, 2025, 10:09:49 AM9/23/25
to django-...@googlegroups.com
#25508: Add "QuerySet()" to QuerySet.__repr__ to help debugging
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Tim
Type: | Graham
Cleanup/optimization | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Jacob Walls <jacobtylerwalls@…>):

In [changeset:"b2773a39a34f0f0ca768fa1daaf8bf72fca56e06" b2773a3]:
{{{#!CommitTicketReference repository=""
revision="b2773a39a34f0f0ca768fa1daaf8bf72fca56e06"
[5.2.x] Refs #25508 -- Used QuerySet.__repr__ in
docs/ref/contrib/postgres/search.txt.

Backport of efb96138b4af774c22ae6e949410b45d69960357 from main.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25508#comment:8>

Django

unread,
Jan 19, 2026, 9:58:52 AM (5 days ago) Jan 19
to django-...@googlegroups.com
#25508: Add "QuerySet()" to QuerySet.__repr__ to help debugging
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Tim
Type: | Graham
Cleanup/optimization | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Jacob Walls <jacobtylerwalls@…>):

In [changeset:"d6cca8b904de144946453aea93dd627c09abfca9" d6cca8b9]:
{{{#!CommitTicketReference repository=""
revision="d6cca8b904de144946453aea93dd627c09abfca9"
Refs #25508 -- Updated outdated QuerySet.__repr__() results.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25508#comment:9>

Django

unread,
Jan 19, 2026, 9:59:39 AM (5 days ago) Jan 19
to django-...@googlegroups.com
#25508: Add "QuerySet()" to QuerySet.__repr__ to help debugging
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Tim
Type: | Graham
Cleanup/optimization | Status: closed
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Jacob Walls <jacobtylerwalls@…>):

In [changeset:"9814676ea75bfe5c5d5244c50ccfe1f652a2f058" 9814676]:
{{{#!CommitTicketReference repository=""
revision="9814676ea75bfe5c5d5244c50ccfe1f652a2f058"
[6.0.x] Refs #25508 -- Updated outdated QuerySet.__repr__() results.

Backport of d6cca8b904de144946453aea93dd627c09abfca9 from main.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25508#comment:10>
Reply all
Reply to author
Forward
0 new messages