CSS system for Django / Python?

I am wondering if there is something like a template system for Django HTML, for CSS. my searches on this subject do not bring anything useful. I know about things like SASS and CleverCSS, but as far as I can tell, they still do not solve my problem, because I want to dynamically generate a CSS file based on certain conditions, so that a different CSS file will be used in a specific user session. ..

I want to minimize the use of javascript / AJAX for some things (since for an outdated system running in some hospital where they still use IE 6), I am also interested in possible javascript minimization for other projects, well ... so it would be where there is 1 CSS file, but that it may need to be changed depending on the situation (which would have been done with CleverCSS), but the problem is that if I just write the changes to 1 file, it will be accessible to everyone, even if they may have a different "state" of the CSS file depending on the use application, so I want to remove the physical association of the CSS file and, rather, dynamically generate each (so that it is unique to a specific user session), how the Django HTML template system works.

+4
source share
1 answer

The Django template system can be used for any text you like. It was used for HTML most of the time, but it could also be used to create CSS. The CSS link in your HTML can be for a dynamic URL instead of a static file, and the view function can create any context that you like, then the .css template file can create your CSS.

If you have only a few different CSS features, you better work by creating them as static files and using an HTML template to select the CSS file you want by writing another CSS link depending on your conditions.

+6
source

All Articles