#16034: get_field_display: Django needs a filter to allow get_field_display for 
a
dynamic field
---------------------------------------+---------------------------------
               Reporter:  thepapermen  |          Owner:  nobody
                   Type:  New feature  |         Status:  new
              Milestone:               |      Component:  Template system
                Version:  1.3          |       Severity:  Normal
             Resolution:               |       Keywords:
           Triage Stage:  Unreviewed   |      Has patch:  0
    Needs documentation:  0            |    Needs tests:  0
Patch needs improvement:  0            |  Easy pickings:  0
---------------------------------------+---------------------------------
Changes (by thepapermen):

 * needs_better_patch:   => 0
 * needs_tests:   => 0
 * needs_docs:   => 0


Comment:

 I'm talking about something like this:
 {{{#!python
 def human_readable(value, arg):

     if hasattr(value, 'get_' + str(arg) + '_display'):
         return getattr(value, 'get_%s_display' % arg)()
     elif hasattr(value, str(arg)):
         return getattr(value, arg)
     else:
         return settings.TEMPLATE_STRING_IF_INVALID

 register.filter('human_readable', human_readable)
 }}}

 But secure against showing _meta attributes.

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