Changes between Version 7 and Version 8 of ListColumns


Ignore:
Timestamp:
Oct 27, 2010, 10:38:43 AM (14 years ago)
Author:
Alex Kamedov
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ListColumns

    v7 v8  
    33Related ticket: #8054 Move method properties for admin list customization to ModelAdmin
    44
    5 This ticket adds:
     5Ticket goals are:
    66
    7  * beautifully API to admin change list customization
     7 * to change list_display syntax;
     8 * add to list_display_links the same items type support as list_display has (Now Django allows to use in list_display_links only model fields, properties or methods).
    89
    9  * ability to customize and localize 3rd-party application without fork it
     10The current approach for customising list_display seems contrary to the spirit of newforms-admin. Method properties such as .short_description, .boolean and .allow_tags rarely belong in the model definition.
    1011
    11  * ability to apply custom template filters on field value or model method returned value without any magic
    12 
    13  * ability to specify witch field will be used in order for column based on model method
     12In fact, I noted that these options, for customising the look of the list column, duplicate filter functionality. .allow_tags is exactly |safe; |boolean could be a filter provided by django.contrib.admin.templatetags. The case is much more convincing when you take into account user-defined filters: if I already have a filter for presenting values for user consumption, I should not need to provide a model method to replicate or apply that filter.
    1413
    1514
     
    8281        bar_column,
    8382        admin.ListColumn('foo', header='Foo Description', filter='boolean_icon'),
    84         'baz',
     83        admin.ListColumn('baz', filter='truncatewords:"2"|slugify'),
    8584        'bonk',
    8685        admin.ListColumn('ends', filter='timeuntil', header="Ending in"),
     
    9089
    9190}}}
     91
     92In the example
     93
     94{{{
     95admin.ListColumn('baz', filter='truncatewords:"2"|slugify'),
     96}}}
     97
     98would render exactly the same as
     99
     100{{{
     101{{row.baz|truncatewords:"2"|slugify}}
     102}}}
     103
Back to Top