#10171: Key class_attrib missing in result_headers dict used in 
change_list_results
template
--------------------------------------------+-------------------------------
          Reporter:  [email protected]  |         Owner:  nobody
            Status:  closed                 |     Milestone:        
         Component:  django.contrib.admin   |       Version:  SVN   
        Resolution:  invalid                |      Keywords:        
             Stage:  Unreviewed             |     Has_patch:  0     
        Needs_docs:  0                      |   Needs_tests:  0     
Needs_better_patch:  0                      |  
--------------------------------------------+-------------------------------
Comment (by [email protected]):

 Hm. I probably described this problem badly. If function
 ''result_headers'' ends on the line 113 (!!!), it returns only dict
 {"text": header}. But template ''change_list_results.html'' needs value
 ''class_attrib''. If this value missing, the html code looks like this:
 <thINVALID VARIABLE>. This situation occurs, when the column in the list
 is not defined as a field in model but as a function only.

 For example:
 {{{
 #!python
 class Person(models.Model):
     first_name = models.CharField(max_length=50)
     last_name = models.CharField(max_length=50)

     def upper_case_name(obj):
         return ("%s %s" % (obj.first_name, obj.last_name)).upper()
     upper_case_name.short_description = 'Upper Name'

 class PersonAdmin(admin.ModelAdmin):
     list_display = ("first_name", "upper_case_name")
 }}}

 And now see title of the column '''Upper Name''' in the person admin list.
 Correction is simple: Just add ''if'' to the template
 ''change_list_results.html'':
 {{{
 <th{% if header.class_attrib %}{{ header.class_attrib }}{% endif %}>
 }}}
 I hope, it is clear now.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/10171#comment:2>
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to