#27819: Display a warning when django.views.generic.ListView assumes the default
template name
-----------------------------------------+------------------------
Reporter: Maker Bajax | Owner: nobody
Type: Uncategorized | Status: new
Component: Generic views | Version: 1.8
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 |
-----------------------------------------+------------------------
I recently had an issue where it seemed that my code was trying to load a
template for a ListView that I had defined previously, but renamed. Even
though there was no more reference to the old template in another part of
my code, it still gave me "Template not found." I spent a couple of
hours scouring my code for references, deleting .pyc files and checking if
the template had gotten cached in the database or something (It was a
Django CMS project).
Lo and behold, after finally taking the time to set up a debugger and step
through, I found the rogue template name was being derived from the app
and model name as is done here (this is not the same version I'm using,
but the line in question is identical):
https://github.com/django/django/blob/ff8711a825ea9bbe98e873d7aa28ce5135528fec/django/views/generic/list.py#L137
So with respect to that error message-- It was "Template not found." To
the me at that time, that didn't mean, "You didn't define a template, so I
assumed one for you," but "You handed me a bad template name."
I wasn't even aware that the ListView object could accept a template name
(I'm still learning Django TBH) and I thought that was up to some other
layer of the system to handle. At the time I had no idea where the
template name could be coming from.
It would be nice if we could get a warning of some kind when a default is
assumed like this. I know it's a design goal of Django to assume things
that are left undefined, but maybe some warnings, especially at high
verbosity, would be helpful. I even saw some places in the code where an
"ImproperlyConfigured" exception was raised because I hadn't set a
template name, but it was caught by some later code and everything carried
on as if nothing was wrong.
--
Ticket URL: <https://code.djangoproject.com/ticket/27819>
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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/048.8a3c8ea88e110658ad2290ba3a0312f7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.