Tsuna
Tsuna

Reputation: 2198

how to add custom js into ALL admin models? django

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?

Upvotes: 4

Views: 2248

Answers (1)

Neeraj Kumar
Neeraj Kumar

Reputation: 3941

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

Upvotes: 6

Related Questions