I'm trying to include some CSS and JS files into the change form of an object like specified in the doc. Here are me files:
admin.py
#...
class ScribPartAdmin(admin.ModelAdmin):
class Media:
css = {
'all': ('mymarkup.css',)
}
js = ('mymarkup.js',)
admin.site.register(ScribPart, ScribPartAdmin)
#...
models.py
class ScribPart(models.Model):
part = models.IntegerField()
sequence = models.IntegerField()
file = models.FileField(upload_to='audio/')
text = models.TextField()
#...
My 2 media files are included in the change_list
template but 开发者_运维问答not in the change_form
one.
The question is: Why ?
Because I was not pointing to the good locations:
#...
class ScribPartAdmin(admin.ModelAdmin):
class Media:
css = {
'all': ('css/mymarkup.css',)
}
js = ('javascript/mymarkup.js',)
admin.site.register(ScribPart, ScribPartAdmin)
#...
is better.
Apparently Django includes medias that are not found by the collector into the change_list
page but not into the change_form
page. I don't know why (or i'm missing something else)...
精彩评论