Ticket #10229: list_display.diff

File list_display.diff, 1.2 KB (added by Scot Hacker, 13 years ago)

Documentation of need to use real integers in CHOICES tuples for list_display.

  • index.txt

     
    364364      this::
    365365
    366366          list_display = ('__unicode__', 'some_other_field')
     367         
     368    * If the field being represented derives from a CHOICES tuple, and integers
     369      are used as the keys, be sure you're using real integers in the tuple,
     370      not strings that look like integers. Otherwise, ``list_display`` will show
     371      (None) for this field rather than the value you think should be displayed.
     372      For example, this works as expected::
     373     
     374          YEARS = (
     375              (0,'Non-Vintage'),
     376              (9999,'Multi-Vintage'),
     377              (1880,'1880'),
     378              (1881,'1881'),
     379          )
     380         
     381      While this does not::
    367382
     383          YEARS = (
     384            ('0','Non-Vintage'),
     385            ('9999','Multi-Vintage'),
     386            ('1880','1880'),
     387            ('1881','1881'),
     388          )   
     389
    368390    * Usually, elements of ``list_display`` that aren't actual database fields
    369391      can't be used in sorting (because Django does all the sorting at the
    370392      database level).
Back to Top