python - Django 模板 : Embed css from file

标签 python django templates include embed

我正在处理一个电子邮件模板,因此我想嵌入一个 css 文件

<head>
   <style>{{ embed 'css/TEST.css' content here }}</style>
</head>

而不是链接它

<head>
   <link href="{% static 'css/TEST.css' %}" rel="stylesheet" type="text/css">
</head>

有什么想法吗?

最佳答案

我猜你可以使用 include

<style>{% include "/static/css/style.css" %}</style>    

https://docs.djangoproject.com/en/1.9/ref/templates/builtins/#include

但最好在 View 中加载 css 文件的内容,并将其放在 View 的上下文中以将其发送到模板

关于python - Django 模板 : Embed css from file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33607083/

相关文章:

python - NLTK 中的 NgramCollocationFinder

python - django 开发服务器,将 header 添加到静态文件

python - Heroku:将文件放入 bin 文件夹

django - Django admin分页问题

c++ - 自定义分配器兼容性

c++ - 非常简单的可变参数函数的问题

python - 我如何在 Jinja 中创建一个包含模板后面的值的标签?

python - 如何在Python中用前面的数字分割utf-8字符串?

html - FreeMarker模板中字符串过长如何灵活调整列宽?

python - 类型错误 : object of type 'instancemethod' has no len()