Separate JS and CSS output for a media class object for a Django form in a template

I have a simple question. I know how to use django media to host js and css files specified in the media class as follows:

In forms.py for the model

from django import forms

class CalendarWidget(forms.TextInput):
    class Media:
        css = {
            'all': ('pretty.css',)
        }
        js = ('animations.js', 'actions.js')

In the template file

{{ form.media }}

However, I want to host JS and CSS separately. This means that I want to put CSS in the chapter section and JS before the body tag. So how can I achieve this using assembly in tags? Is it possible?

PS I can not find out the information from the django documentation. (Maybe I'm looking the wrong way). So give me a hint.

+4
source share
1 answer

{{form.media.css}} {{form.media.js}} , .

subsets-of-assets.

+7

All Articles