I try to add my custom javascript to some change_form templates.
Before having installed Grappelli, I could do that by extending
change_form.html of admin and creating sub folders under the templates
with my module names.
For example my tree hireachy was like :
+templates
++admin_copies
+++change_form.html (I have added extra js blocks)
++admin
+++employer
++++employer
+++++change_form.html
++++employer_new
+++++change_form.html
As you understand I have a model named “Employer”. I can add my custom
js methods under the change_form.html files.
However, this kind of inheritance cause javascript/breadcrumbs
problems with Grappelli.
How can I add simply my custom javascript functions for each model
separetly ?
Create a subclass of
ModelAdmin, and define the custom js in itsMediaclass.admin.py, in the same folder as themodels.pythat hasEmployer:Read more here