#14529: Save messages for proxy models show a crazy verbose_name
-------------------------------------------+--------------------------------
          Reporter:  rlaa...@wiktel.com    |         Owner:  nobody
            Status:  new                   |     Milestone:  1.3   
         Component:  django.contrib.admin  |       Version:  SVN   
        Resolution:                        |      Keywords:        
             Stage:  Accepted              |     Has_patch:  1     
        Needs_docs:  0                     |   Needs_tests:  1     
Needs_better_patch:  1                     |  
-------------------------------------------+--------------------------------
Comment (by julien):

 Here's a simple test case:

 Model:
 {{{
 #!python
 from django.db import models

 class Book(models.Model):
     name = models.CharField(max_length=100)
     author = models.CharField(max_length=100, blank=True)
 }}}

 Admin:
 {{{
 #!python
 from django.contrib import admin

 from .models import Book

 class BookAdmin(admin.ModelAdmin):
     list_display = ('name',)

     def queryset(self, request):
         return super(BookAdmin, self).queryset(request).only('name')

 admin.site.register(Book, BookAdmin)
 }}}

 Narrowing down the issue with `print` statements in
 `django.contrib.admin.options`:
 {{{
 #!python

     def change_view(self, request, object_id, extra_context=None):
         ...
                 print "Before:" + force_unicode(opts.verbose_name)
                 return self.response_change(request, new_object)
         ...

     def response_change(self, request, obj):
         """
         Determines the HttpResponse for the change_view stage.
         """
         opts = obj._meta
         print "After:" + force_unicode(opts.verbose_name)
         ...
 }}}

 This results in:
 {{{
 Before:book
 After:book_ deferred_author
 }}}

 So apparently the issue occurs when the meta options are reloaded in
 `response_change()` with opts = obj._meta.

 Note that the issue only arises with the change view. With the add view,
 the correct verbose names are displayed.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/14529#comment:3>
Django <http://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 django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to