Django: adding new admin_tags

/ Published in: Django
Save to your folder(s)

First: create a file under djangoapp/templatetags where you define your tags [e.g.:]:

Second: create the html snippets that get loaded in those tags [e.g., personfactoid_info.html]:

Third: in mytemplates/admin/ modify change_form.html (if you don't have it just copy it from the django-admin app). You must add a placeholder for the new templatetags (probably you want to add it at the bottom of the page):

FOurth: create a new change_form.html in the same directory as above, but under your model template [e.g., mytemplates/admin/myapp/mymodel/change_form.html] so to override the behaviour just for that. The 'object_id' variable is passed by the admin template by default:

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.