Extending Django Admin Templates - altering change list -


a (not so) quick question extending django admin templates.

i'm trying change result list (change list in django lingo) of specific model adding intermediary row between result rows (row1 , row2 classes) contains objects related object.

i searched code haven't found way this. pointers appreciated. code too.

ps: know should designing own interface, internal project , don't have time spare. also, django interface nice.

thank in advance.

step 1: overriding changelist view:
you'll have override template opposed specifying 1 can add_view / change_view.

first things first, override def changelist_view(self, request, extra_context=none): in modeladmin. remember call super(foo, self).changelist_view(request, extra_context) , return that.

step 2: overriding templates:
next, override app-specific changelist template @ templates/admin/my_app/my_model/change_list.html (or not.. can use global changelist override if you'd like).

step 3: copy result list functionality
think can either copy result_list functionality (define new template tag) or fake copying , pasting result_list function , template include view.

# django.contrib.admin.templatetags.admin_list def result_list(cl):     """     displays headers , data list     """     return {'cl': cl,             'result_hidden_fields': list(result_hidden_fields(cl)),             'result_headers': list(result_headers(cl)),             'results': list(results(cl))} result_list = register.inclusion_tag("admin/change_list_results.html")(result_list) 

you can see admin uses admin/change_list_results.html template render individual columns you'll need use 1 of methods replace template tag.

since it's looking global template, wouldn't override it.

either define new tag w/ new template view, or send result_list(cl) template directly , adopt admin/change_list_results.html use directly in change_list.html template.


Comments

Popular posts from this blog

c# - BasicHttpBinding equivalent CustomBinding using WCF Client and PHP WebService -

sql server - python to mssql encoding problem -

java - SNMP4J General Variable Binding Error -