views:

147

answers:

2

I am attempting to override/extend the header for the Django admin in version 1.2.1. However when I try to extend the admin template and simply change what I need documented here: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-vs-replacing-an-admin-template), I run into a recursion problem.

I have an index.html file in my project's templates/admin/ directory that starts with

{% extends "admin/index.html" %}

But it seems that this is referencing the local index file (a.k.a. itself) rather than the default Django copy. I want to extend the default Django template and simply change a few blocks. When I try this file, I get a recursion depth error.

How can I extend parts of the admin? Thanks.

SOLUTION: Rather than extending, I copied the files into my_templates_directory/admin/ and just edited them as I wished. This solution was acceptable, though not ideal.

+1  A: 

The contrib/admin/templates/admin path needs to go before the directory with your custom admin templates in your list of paths in TEMPLATE_DIRS in your settings.py

Daniel DiPaolo
I put "C:/Python26/Lib/site-packages/django/contrib/admin/templates/admin" before my project template directory in TEMPLATE_DIRS, but I still cannot get the template overrriding working. I am still using the same extends line from my original post. Does that need changed as well?
jcady
A: 

Create a symlink to contrib/admin/templates/admin/ in your templates directory and use it in your {% extends %} statement.

cd /path/to/project/templates/
ln -s /path/to/django/contrib/admin/templates/admin/ django_admin

Now in your admin/index.html use {% extends "django_admin/index.html" %}

EDIT: Just realized that you're on windows... Not sure how to achieve the same results. Hopefully this still helps the folks on linux.

ejb