3

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 ?

Pierre de LESPINAY
  • 44,700
  • 57
  • 210
  • 307

1 Answers1

5

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)...

Pierre de LESPINAY
  • 44,700
  • 57
  • 210
  • 307