Skip to main content

Add dynamic css & js resources to django's admin site.

Project description


Add dynamic css & js resources to django's admin site.


pip install django-dynamic-resource-admin



  1. We use template override mechanism, so you MUST add app name django_dynamic_resource_admin into INSTALLED_APPS.

  2. The parameter request pass to get_css&get_js is the request of this view.

  3. The parameters **kwargs pass to get_css&get_js are the paramters of admin view prameters.

  4. Every extra js part is wrappered with closure function, so that they will be NO local variables conflict. If you want to add a global variable, name it like: = 123;.

        ...your js code...




from django.contrib import admin
from django_dynamic_resource_admin.admin import DjangoDynamicResourceAdmin
from .models import Book

class BookAdmin(DjangoDynamicResourceAdmin, admin.ModelAdmin):
    def get_css(self, request, **kwargs):
        csses = super().get_css(request)
        csses += [
    background-color: red;
        return csses, BookAdmin)

How to add your custom css&js?

  • Override get_css to add extra css.
  • Override get_js to add extra js.
def get_css(self, request, **kwargs):
    extra_css = super().get_css(request, **kwargs)
    extra_css += [
    return extra_css

def get_js(self, request, **kwargs):
    extra_js = super().get_js(request, **kwargs):
    extra_js += [
        """window.msg="hello world";""",
    return extra_js


v0.1.0 2020/03/13

  • First realse.

Project details

Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-dynamic-resource-admin, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size django-dynamic-resource-admin-0.1.0.tar.gz (4.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page