How to render a template with dynamic CSS?

后端 未结 3 1217
旧巷少年郎
旧巷少年郎 2021-01-12 08:27

I want to create a dynamic CSS file in a view and then render a template which loads that CSS file. Depending on the arguments given to the view, the CSS may have different

3条回答
  •  北荒
    北荒 (楼主)
    2021-01-12 09:03

    views.py:

    def create_css_file(request, color):
        f = color
        return render_to_response('mytemplate.html', locals())
    

    template:

    
    

    Don't create css file on the fly it is unnecessary.

提交回复
热议问题