For Django's stock (out of the box) admin, adding custom JavaScript is as simple/easy as:
class ContentAdmin(admin.ModelAdmin):
model = Content
class Media:
js = ('js/content.js',)
Works beautifully in Django 1.8.4 (have tested it).
Now I'm using django-xadmin in my project for a enhanced user interface/experience. The problem is that the code above doesn't add the custom JS to xadmin's views.
Went over the project's readme, "documentation" (or lack of) and even delved into the source code. The farthest I got was figuring out that overriding get_media() method it actually adds the custom JS to the view, but since it overrides the parent's call all other xadmin's JSs and CSSs aren't loaded.
class ContentAdmin(admin.ModelAdmin):
model = Content
class Media:
js = ('js/content.js',)
def get_media(self):
# Tried "super(ContentAdmin, self).get_media()"
## » Says method doesn't exists
# Tried "super(ContentAdmin, self).media"
## » Exactly the same thing as "self.media" below
media = self.media
print("#### MEDIA IS {}".format(media.__dict__))
return media
That prints out:
#### MEDIA IS {'_css': {}, '_js': ['/static/admin/js/core.js', '/static/admin/js/admin/RelatedObjectLookups.js', '/static/admin/js/jquery.js', '/static/admin/js/jquery.init.js', '/static/admin/js/actions.js', 'js/content.js']}
My custom JS ('js/content.js') is definitely there and gets loaded, but all other default xadmin's CSS and JS are gone.
Any ideas on how to add the custom JS without overriding the parent's media properties? OR how to keep it when overriding?