Django

Code

Changeset 3652

Show
Ignore:
Timestamp:
08/23/06 10:40:41 (2 years ago)
Author:
adrian
Message:

Added some helpful hints to list_display documentation in docs/model-api.txt

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/model-api.txt

    r3620 r3652  
    12231223 
    12241224    * ``ManyToManyField`` fields aren't supported, because that would entail 
    1225         executing a separate SQL statement for each row in the table. 
    1226  
    1227     * If the field is a ``BooleanField``, Django will display a pretty "on" or 
    1228       "off" icon instead of ``True`` or ``False``. 
     1225      executing a separate SQL statement for each row in the table. If you 
     1226      want to do this nonetheless, give your model a custom method, and add 
     1227      that method's name to ``list_display``. (See below for more on custom 
     1228      methods in ``list_display``.) 
     1229 
     1230    * If the field is a ``BooleanField`` or ``NullBooleanField``, Django will 
     1231      display a pretty "on" or "off" icon instead of ``True`` or ``False``. 
    12291232 
    12301233    * If the string given is a method of the model, Django will call it and 
     
    12621265                  return '<span style="color: #%s;">%s %s</span>' % (self.color_code, self.first_name, self.last_name) 
    12631266              colored_name.allow_tags = True 
     1267 
     1268    * The ``__str__()`` method is just as valid in ``list_display`` as any 
     1269      other model method, so it's perfectly OK to do this:: 
     1270 
     1271          list_display = ('__str__', 'some_other_field') 
     1272 
     1273    * For any element of ``list_display`` that is not a field on the model, the 
     1274      change list page will not allow ordering by that column. This is because 
     1275      ordering is done at the database level, and Django has no way of knowing 
     1276      how to order the result of a custom method at the SQL level. 
    12641277 
    12651278``list_display_links``