[Django]-Django 1.6 admin panel customization

6đź‘Ť

Actually, the answer from @mayankTUM is not correct. It does not follow the django design philosophies and should not be implemented (@mayankTUM himself mentions one of the problems of his solution however there are many, many more)!

Basically, what you need to do can be done by overriding the admin templates. Because there are some problems with that (I will explain later), here’s exactly what
I did to solve your requirement:

  1. Created a directory named admin in my templates folder.
  2. Copied there the change_list.html template from <django>\contrib\admin\templates\admin\change_list.html.
  3. Added the following to the end of the new change_list.html: {% block content_title %}Hello world!{% endblock %}

Now, instead of “Select … to change” it will print “Hello world!”

I have to notice that copying the whole change_list.html is not DRY – it’d be much better if I just created the file, made it extend from admin/change_list.html and add the content_title. However this is not working and will lead to infinite recursion (please check this bug report https://code.djangoproject.com/ticket/15053 ) — this is the problem to which I was referring before. A better solution that copying over the whole template is discussed in the following questions:

Django: Overriding AND extending an app template
and
How to override and extend basic Django admin templates? and
django override admin template

PS: My TEMPLATE_DIRS and TEMPLATE_LOADERS project settings are these:

TEMPLATE_DIRS = (
    PROJECT_PATH.child('templates'),
)

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
)
👤Serafeim

Leave a comment