Code

Changes between Version 33 and Version 34 of NewformsHOWTO


Ignore:
Timestamp:
06/04/08 15:10:40 (6 years ago)
Author:
Victor Andrée <victor.andree@…>
Comment:

trimmed the code and fixed my formatting

Legend:

Unmodified
Added
Removed
Modified
  • NewformsHOWTO

    v33 v34  
    201201 
    202202First, move results and extended_result_list away. I created a separate module called admin_extras and put them (rewritten) 
    203 in {{{ __init__.py }}}: 
    204  
    205 {{{ admin_extras/__init__.py }}} 
     203in ```__init__.py```: 
     204 
     205```admin_extras/__init__.py``` 
    206206{{{ 
    207207#!python 
     
    220220def extended_result_list(cl, additional_cols): 
    221221    headers = list(admin_list.result_headers(cl)) 
    222     for h in additional_cols: 
    223         headers.append(h) 
     222    headers.extend(additional_cols) 
    224223     
    225224    # Parse the templates once 
     
    236235have an Article-model and want to display an extra column with publishing options. 
    237236 
    238 {{{ articles/templatetags/change_list_extras.py }}} 
     237I wouldn't really recommend the name ```change_list_extras```, since you probably want one of these 
     238for every model (to keep them decoupled). ```<model_name>_change_list_extras``` or ```<model_name>_admin_extras``` 
     239are probably better candidates. 
     240 
     241```articles/templatetags/change_list_extras.py``` 
    239242{{{ 
    240243#!python 
     
    258261modify article_result_list to send a dictionary of its own to merge with the one in results. 
    259262 
    260 I haven't tested using {{{ {% url %} }}} myself, but I see no reason why it wouldn't work! 
     263I haven't tested using ```{% url %}``` myself, but I see no reason why it wouldn't work! 
    261264 
    262265You use this in a custom change_list-template for your model admin: