#24689: DetailView & ListView get_template_name fails with deferred QuerySet
---------------------------------+--------------------
Reporter: BertrandBordage | Owner: nobody
Type: Bug | Status: new
Component: Generic views | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+--------------------
Suppose you define a view like this:
{{{
from django.views.generic import DetailView
from django.contrib.auth.models import User
class UserDetail(DetailView):
model = User
queryset = User.objects.defer('password')
}}}
If you try to use the view, the default template name is
{{{auth/user_deferred_password_detail.html}}} instead of
{{{auth/user_detail.html}}}.
This is because Django creates a proxy model each time you use defer/only.
And therefore {{{User.objects.defer('password')[0]._meta.model_name}}} is
{{{'user_deferred_password'}}}.
{{{(DetailView|ListView).get_template_name}}} should ckeck if
{{{model._deferred}}} and use {{{model._meta.proxy_for_model}}} to get the
original model.
--
Ticket URL: <https://code.djangoproject.com/ticket/24689>
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/058.d8f24e391180baf0c69d106d55df53f7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.