[Django] #28719: Better exception message when get_queryset returns None

13 views
Skip to first unread message

Django

unread,
Oct 17, 2017, 9:58:07 AM10/17/17
to django-...@googlegroups.com
#28719: Better exception message when get_queryset returns None
---------------------------------------------+------------------------
Reporter: Bjorn Kristinsson | Owner: nobody
Type: Bug | Status: new
Component: Generic views | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
---------------------------------------------+------------------------
One of my `ListViews` suddenly started raising `TemplateDoesNotExist` with
a rather cryptic (to me) message:

{{{
Template-loader postmortem

Django tried loading these templates, in this order:

Using engine :
This engine did not provide a list of tried templates.
}}}

It took me a while to realise this was because my get_queryset wasn't
returning anything. It did some filtering based on user settings, and I
didn't have a fallback for when none of the filtering steps applied.

Thought it might be helpful to have a better message is no template names
are found and `object_list` is `None`. Suggesting: "Expected a queryset,
but found None. Please check that <cls>.get_queryset() returns a
queryset." Pull request coming up.

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

Django

unread,
Oct 17, 2017, 9:59:50 AM10/17/17
to django-...@googlegroups.com
#28719: Better exception message when get_queryset returns None
-------------------------------------+-------------------------------------
Reporter: Bjorn Kristinsson | Owner: Bjorn
| Kristinsson
Type: Bug | Status: assigned

Component: Generic views | Version: master
Severity: Normal | Resolution:

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

* owner: nobody => Bjorn Kristinsson
* status: new => assigned


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

Django

unread,
Oct 17, 2017, 10:06:33 AM10/17/17
to django-...@googlegroups.com
#28719: Better exception message when get_queryset returns None
-----------------------------------+--------------------------------------
Reporter: Bjorn Kristinsson | Owner: (none)

Type: Bug | Status: new
Component: Generic views | Version: master
Severity: Normal | Resolution:

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

* status: assigned => new
* owner: Bjorn Kristinsson => (none)


Comment:

Created a pull request, https://github.com/django/django/pull/9255, not
entirely sure why the tests are failing.

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

Django

unread,
Oct 17, 2017, 4:00:31 PM10/17/17
to django-...@googlegroups.com
#28719: Better exception message when get_queryset returns None
-----------------------------------+--------------------------------------
Reporter: Bjorn Kristinsson | Owner: yauneyz
Type: Bug | Status: assigned

Component: Generic views | Version: master
Severity: Normal | Resolution:

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

* owner: (none) => yauneyz


* status: new => assigned


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

Django

unread,
Oct 17, 2017, 4:30:00 PM10/17/17
to django-...@googlegroups.com
#28719: Better exception message when get_queryset returns None
-----------------------------------+--------------------------------------
Reporter: Bjorn Kristinsson | Owner: (none)

Type: Bug | Status: new
Component: Generic views | Version: master
Severity: Normal | Resolution:

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

* owner: Zac Yauney => (none)


* status: assigned => new


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

Django

unread,
Oct 19, 2017, 3:44:29 AM10/19/17
to django-...@googlegroups.com
#28719: Better exception message when get_queryset returns None
-------------------------------------+-------------------------------------

Reporter: Bjorn Kristinsson | Owner: (none)
Type: | Status: new
Cleanup/optimization |

Component: Generic views | Version: master
Severity: Normal | Resolution:

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

* type: Bug => Cleanup/optimization


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

Django

unread,
Oct 19, 2017, 6:32:33 AM10/19/17
to django-...@googlegroups.com
#28719: Better exception message when get_queryset returns None
-------------------------------------+-------------------------------------
Reporter: Bjorn Kristinsson | Owner: Bjorn
Type: | Kristinsson
Cleanup/optimization | Status: assigned

Component: Generic views | Version: master
Severity: Normal | Resolution:

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

* owner: (none) => Bjorn Kristinsson


* status: new => assigned


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

Django

unread,
Oct 23, 2017, 2:47:25 AM10/23/17
to django-...@googlegroups.com
#28719: Better exception message when get_queryset returns None
-------------------------------------+-------------------------------------

Reporter: Bjorn Kristinsson | Owner: (none)
Type: | Status: new
Cleanup/optimization |
Component: Generic views | Version: master
Severity: Normal | Resolution:

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

* cc: Bjorn Kristinsson (added)


* status: assigned => new

* owner: Bjorn Kristinsson => (none)


Comment:

Oki, guess someone else than me needs to move this forward. The PR is
passing tests now, comments addressed - but someone else needs to accept
or reject it.

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

Django

unread,
Nov 1, 2017, 1:11:42 PM11/1/17
to django-...@googlegroups.com
#28719: Better exception message when get_queryset returns None
-------------------------------------+-------------------------------------
Reporter: Bjorn Kristinsson | Owner: (none)
Type: | Status: new
Cleanup/optimization |
Component: Generic views | Version: master
Severity: Normal | Resolution:

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

* cc: hpfn (added)


Comment:

Hi,

I read the patch and ran the tests.

Ran 202 tests in 3.730s
OK

It seems that the patch does what the author wants. If
there is no information at all raise 'ImproperlyConfigured'.

patch ok
tests ok
docs ok

I am not changing to 'Ready for checkin' because this is
my first time doing a review.

Regards,
Herbert

--
Ticket URL: <https://code.djangoproject.com/ticket/28719#comment:6>

Django

unread,
Nov 1, 2017, 5:25:04 PM11/1/17
to django-...@googlegroups.com
#28719: Better exception message when get_queryset returns None
-------------------------------------+-------------------------------------
Reporter: Bjorn Kristinsson | Owner: Tomer
Type: | Chachamu
Cleanup/optimization | Status: assigned

Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tomer Chachamu):

* owner: (none) => Tomer Chachamu


* status: new => assigned

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/28719#comment:7>

Django

unread,
Nov 1, 2017, 5:36:50 PM11/1/17
to django-...@googlegroups.com
#28719: Better exception message when get_queryset returns None
--------------------------------------+------------------------------------

Reporter: Bjorn Kristinsson | Owner: (none)
Type: Cleanup/optimization | Status: new

Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Tomer Chachamu):

* owner: Tomer Chachamu => (none)
* needs_better_patch: 0 => 1


* status: assigned => new


--
Ticket URL: <https://code.djangoproject.com/ticket/28719#comment:8>

Django

unread,
Nov 2, 2017, 4:03:32 AM11/2/17
to django-...@googlegroups.com
#28719: Better exception message when get_queryset returns None
--------------------------------------+------------------------------------
Reporter: Bjorn Kristinsson | Owner: (none)
Type: Cleanup/optimization | Status: new

Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Bjorn Kristinsson):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/28719#comment:9>

Django

unread,
Nov 2, 2017, 11:15:55 AM11/2/17
to django-...@googlegroups.com
#28719: Better exception message when get_queryset returns None
-------------------------------------+-------------------------------------

Reporter: Bjorn Kristinsson | Owner: (none)
Type: | Status: new
Cleanup/optimization |

Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tomer Chachamu):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/28719#comment:10>

Django

unread,
Nov 7, 2017, 6:37:42 PM11/7/17
to django-...@googlegroups.com
#28719: Add a helpful exception message when ListView.get_queryset() returns None

-------------------------------------+-------------------------------------
Reporter: Bjorn Kristinsson | Owner: (none)
Type: | Status: new
Cleanup/optimization |
Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/28719#comment:11>

Django

unread,
Nov 7, 2017, 7:04:46 PM11/7/17
to django-...@googlegroups.com
#28719: Add a helpful exception message when ListView.get_queryset() returns None
-------------------------------------+-------------------------------------
Reporter: Bjorn Kristinsson | Owner: Tim
Type: | Graham <timograham@…>
Cleanup/optimization | Status: closed

Component: Generic views | Version: master
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: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* owner: (none) => Tim Graham <timograham@…>
* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"ac6a4eb9f95138628a7eec76bee91eb067af80a9" ac6a4eb]:
{{{
#!CommitTicketReference repository=""
revision="ac6a4eb9f95138628a7eec76bee91eb067af80a9"
Fixed #28719 -- Added a helpful exception if
MultipleObjectTemplateResponseMixin doesn't generate any template names.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28719#comment:12>

Reply all
Reply to author
Forward
0 new messages