4

as this url mentioned https://docs.djangoproject.com/en/dev/topics/forms/media/#assets-as-a-static-definition I know that and it does work by adding each custom js into each model one by one BUT is there a way to add into ALL models so I do not have to add each model one by one?

1
  • 2
    why not make the base_site.html of your django admin extend and add all the custom js and css that you want to add. so that in admin all the pages will have the css and js? Commented Jul 8, 2017 at 4:08

1 Answer 1

6

Make an admin folder inside the templates folder and then create a base.html file or add below code in html file:

{% extends 'admin/base.html' %}
{% block extrahead %}
<<< add your css and js >>>
{% endblock %}

but make sure project app name must be above from django.contrib.admin in INSTALLED_APP of django settings

Sign up to request clarification or add additional context in comments.

2 Comments

thx thx, this does work event hough I am not sure what you meant by app name must be above
this heads custom javascript in head tag, I need to add it before end of body tag

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.