194 | | The admin is now rendered using separate templates. These can be overloaded, meaning the admin is a bit easily customizable. |
195 | | Inline editing can use a custom template, reather than using edit_inline=meta.TABULAR or meta.SOURCE, just use a path to a template, eg edit_inline="edit_inline_horizontal". |
196 | | |
197 | | This does require knowing the contents of the context for that template which is undocumented. Also this will probably change to a class to allow more flexibility, eg processing for style/grouping logic etc. |
| 194 | The admin is now rendered using separate templates. These can be overloaded, meaning the admin is a bit more easily customizable. |
| 195 | |
| 196 | An example is change forms - these are the forms used to modify and add objects in the admin. The templates are selected in the following order : |
| 197 | |
| 198 | admin/<app_label>/<object_name>/change_form |
| 199 | admin/<app_label>/change_form |
| 200 | admin/change_form |
| 201 | |
| 202 | So it is possible to change the form just for one kind of object. |
| 203 | This makes it possible to add in extra information or change existing blocks eg branding. |
| 204 | |
| 205 | So if we take the polls app as an example, we may want to customise the admin page just for the polls object. |
| 206 | |
| 207 | We create a file {{{admin/polls/polls/change_form.html}}} in our apps template directory, with the contents: |
| 208 | {{{ |
| 209 | |
| 210 | {%extends "admin/change_form" %} |
| 211 | |
| 212 | {% block branding %} Customised title {% endblock %} |
| 213 | {% block after_field_sets %} Some interesting information after the field sets {% endblock %} |
| 214 | |
| 215 | }}} |
| 216 | |
| 217 | This works using normal template inheritance, so make sure you inherit from the right thing. |
| 218 | |
| 219 | In the change forms, the following blocks are available for custom overriding: |
| 220 | |
| 221 | branding - included from "admin/base" |
| 222 | form_top - at the top of the form after the title. |
| 223 | after_field_sets - after standard field sets, before the related objects |
| 224 | after_related_objects - after edit_inline objects |
| 225 | |
| 226 | |
| 227 | Inline editing can be customised. rather than using edit_inline=meta.TABULAR or meta.SOURCE, you can define a custom inline editing mode. This is done by subclassing BoundRelatedObject, and using that class. eg edit_inline=HorizontalScroller. |