#4829: verbose_name(_plural) not accessible in templates (contrib.contenttype)
----------------------------------------------------------------+-----------
          Reporter:  David Danier <[email protected]>  |         
Owner:  nobody
            Status:  closed                                     |     
Milestone:        
         Component:  Contrib apps                               |       
Version:  SVN   
        Resolution:  wontfix                                    |      
Keywords:        
             Stage:  Design decision needed                     |     
Has_patch:  1     
        Needs_docs:  0                                          |   
Needs_tests:  0     
Needs_better_patch:  0                                          |  
----------------------------------------------------------------+-----------
Comment (by pressureman):

 Another idea would be a simple template tag that fetches the verbose_name
 or verbose_name_plural, and renders the text. This is useful for the
 django.views.generic.list_detail.object_list view.

 {{{
 #!python
 @register.simple_tag
 def object_count(paginator):
     if paginator.count == 1:
         name = paginator.object_list.model._meta.verbose_name
     else:
         name = paginator.object_list.model._meta.verbose_name_plural
     text = ungettext_lazy('%(count)d %(name)s', '%(count)d %(name)s',
 paginator.count) % {'count': paginator.count, 'name': name}
     return text
 }}}

 The tag can be called from the template context as `{% object_count
 page_obj.paginator %}` since the generic view automatically populates the
 the page_obj variable.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/4829#comment:7>
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