Changes between Version 7 and Version 8 of ListColumns
- Timestamp:
- Oct 27, 2010, 10:38:43 AM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ListColumns
v7 v8 3 3 Related ticket: #8054 Move method properties for admin list customization to ModelAdmin 4 4 5 T his ticket adds:5 Ticket goals are: 6 6 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). 8 9 9 * ability to customize and localize 3rd-party application without fork it 10 The 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. 10 11 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 12 In 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. 14 13 15 14 … … 82 81 bar_column, 83 82 admin.ListColumn('foo', header='Foo Description', filter='boolean_icon'), 84 'baz',83 admin.ListColumn('baz', filter='truncatewords:"2"|slugify'), 85 84 'bonk', 86 85 admin.ListColumn('ends', filter='timeuntil', header="Ending in"), … … 90 89 91 90 }}} 91 92 In the example 93 94 {{{ 95 admin.ListColumn('baz', filter='truncatewords:"2"|slugify'), 96 }}} 97 98 would render exactly the same as 99 100 {{{ 101 {{row.baz|truncatewords:"2"|slugify}} 102 }}} 103