Changes between Version 2 and Version 3 of ListColumns
- Timestamp:
- Oct 13, 2010, 7:29:46 AM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ListColumns
v2 v3 19 19 Arguments: 20 20 21 * field_name - model field or model method name21 * field_name - calable function or string with model field, Model method name or current ModelAdmin method name. 22 22 23 23 Keyword arguments: 24 24 25 * header - change list column header. If not provided standard algorithm to header column calculation will be used. 25 26 26 * header - change list column header. If not provided standard algoritm to header column calculation will be used.27 * filter - template filters will be apllied to value on output. It is string like this 'filter1|filter2:"arg"'. 27 28 28 * filter - template filters will be apllied to value on output.29 * load_filters - list of required template tags libraries. This libraries will be load before apply template filters to output value. Eg.: ['tagging_tags', 'tagging_autocomplite_tags'] 29 30 30 * load_filters - list of required template tags libraries. This libraries will be load before apply template filters to output value.31 * order_field - string with model field name witch will be used to provide order by this column. If it provided for callable functions, its will be called with this field value in first argument instead of current object instance (this feature exists at least at svn rev. 14188 but currently is not documented). 31 32 32 * order_field - specify witch field will be used to prowide order by this column. 33 34 * value_map - choices used to mapping display value 33 * value_map - choices used to mapping display value. This can redefine choices from model field for shown in admin changelist. 35 34 36 35 ==== Example ==== … … 49 48 return ... 50 49 get_bar_column.allow_tags = True 50 get_bar_column.short_description = 'Bar' 51 51 52 52 def timeuntil_ends(): … … 73 73 74 74 class AccountAdmin(admin.ModelAdmin): 75 76 def formated_bonk(bonk): 77 return ... 78 75 79 list_display = [ 76 admin.ListColumn('foo', header='Foo Description', filter='boolean '),80 admin.ListColumn('foo', header='Foo Description', filter='boolean_icon'), 77 81 admin.ListColumn('get_bar', filter='safe', order_field='bar'), 78 82 'baz', 79 83 'bonk', 80 admin.ListColumn('ends', filter='timeuntil', header="Ending in") 84 admin.ListColumn('ends', filter='timeuntil', header="Ending in"), 85 admin.ListColumn('formated_bonk', order_field="bonk") 81 86 ] 82 87