Add Custom HTML to Django Admin Form Templates

Django
2013-09-21 13:04 (11 years ago) ytyng

1. Define change_form_template in the admin.py module

Specify the location of the custom template

admin.py

class BookmarkletAdmin(admin.ModelAdmin):
    change_form_template = 'bookmarklet/admin/change_form.html'

2. Write the template

It's easier to write by inheriting admin/change_form.html.

{% extends 'admin/change_form.html' %}

{% block field_sets %}
{% for fieldset in adminform %}
  {% include "admin/includes/fieldset.html" %}
{% endfor %}

Write something you like here
{% endblock %}
Currently unrated

Comments

Archive

2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011