= Extending the Admin Templates = === Intro === Django's admin stuff is great. Often, you would like to just add just a little and you would be all set. For example it would be nice to be able to add links to related data on a change form (detail). With 1 little hack, this is easy. The hack is that you need to copy (if you are on Windows, `link` on Nixes) the admin template that you want to extend so that the template loader does not get confused. (Of course, there is probably some simpler mechanism I have not come across or recognized yet, but... live and learn.) === Steps === 1. make a directory in your template path named ``admin_copies`` 2. copy change_form.html from your Django install's contrib/admin/templates/admin 3. create the template to override admin, in this case admin/auction/participant/change_form.html (the template loader find it because it looks first in your template_dirs before looking in the app directories, i.e. django.contrib.admin.) 4. your change_form.html will look something like: {{{ {% extends "admin_copies/change_form.html" %} {% block coltype %}colMS{% endblock %} {% block sidebar %}
{% endblock %} }}} This makes the layout use a sidebar and populates it with some links for related functions or data. === Conclusion === You need the admin_copies directory because you can not extend admin/change_form since it will never be found--you are editing the very file that overrides it. So you give the template loader another place to look. Hence, the copy. The above template--with some CSS--produces: [[Image(change_form.PNG, top)]] All very neat and clean.