2👍
✅
Create a subclass of ModelAdmin
, and define the custom js in its Media
class.
admin.py
, in the same folder as the models.py
that has Employer
:
from django.contrib import admin
from models import Employer
class EmployerAdmin(admin.ModelAdmin):
class Media:
js = ("js/custom.js",) # This paths are appended to your MEDIA_URL setting
admin.site.register(Employer, EmployerAdmin)
Source:stackexchange.com