#18809: MultipleObjectTemplateResponseMixin should handle a generic
EmptyQuerySet
-------------------------------+--------------------------------------
Reporter: benjaoming | Owner: nobody
Type: Bug | Status: closed
Component: Generic views | Version: 1.4
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 msopacua):
* status: new => closed
* resolution: => invalid
Comment:
Replying to [ticket:18809 benjaoming]:
> {{{#!python
> if hasattr(self.object_list, 'model'):
> opts = self.object_list.model._meta
> names.append("%s/%s%s.html" % (opts.app_label,
opts.object_name.lower(), self.template_name_suffix))
> }}}
>
>
> ...it should be verified that self.object_list is not None
{{{#!python
>>> foo = None
>>> hasattr(foo, 'model')
False
}}}
What should be verified is that self has the object_list attribute.
There's a difference. If you use MultipleObjectTemplateResponseMixin
without BaseListView, then it's your responsibility to populate
self.object_list through the `get()` method.
> On a secondary note, I don't understand why get_template_names is even
called when I have defined template_name -- seems like bug?
Because it's plural. get_template_names should return ''all possible
candidates for a template name''. Feel free to re-open if you think Django
is still at fault, but to me it seems more like a documentation issue and
the CBV docs are greatly improving.
--
Ticket URL: <https://code.djangoproject.com/ticket/18809#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.