﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
24689	DetailView get_template_name and get_context_object_name fail with deferred QuerySet	Bertrand Bordage	nobody	"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.get_template_name}}} should ckeck if {{{model._deferred}}} and use {{{model._meta.proxy_for_model}}} to get the original model."	Bug	closed	Generic views	dev	Normal	fixed			Accepted	1	0	1	0	0	0
