Django: Is it possible to attach media files (css, javascript etc) to a View-class?

Posted by mrmclovin on Stack Overflow See other posts from Stack Overflow or by mrmclovin
Published on 2012-10-07T21:12:47Z Indexed on 2012/10/07 21:37 UTC
Read the original article Hit count: 116

I can't fins any information on how to define css or javascript files in a view like:

class MyView(View): ....

class Media: css = { 'all' : 'mystyle.css' }

If you have a form you can do like: class MyForm(ModelForm): ....

class Media: css = { 'all' : 'mystyle.css' }

And then in the template you can print the files like; {{ form.media.css }}

I like that Syntax very much and I like to keep the View-specific css files in the app-directory.

Does anyone know if it's possible?

Thanks!

© Stack Overflow or respective owner

Related posts about css

Related posts about django