Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django在电子邮件模板中呈现图像_Django - Fatal编程技术网

Django在电子邮件模板中呈现图像

Django在电子邮件模板中呈现图像,django,Django,我已经创建了如下所示的电子邮件模板 {%load staticfiles%} <h1 style="color:red; background-image:url('../images/contact.jfif')">Welcome {{contact_name}}!</h1><br> Your username is {{ contact_email }} and your content is {{ form_content }}. <img src

我已经创建了如下所示的电子邮件模板

{%load staticfiles%}

<h1 style="color:red; background-image:url('../images/contact.jfif')">Welcome {{contact_name}}!</h1><br>
Your username is {{ contact_email }} and your content is {{ form_content }}.
<img src="{{ request.get_host }}{% static 'images/logo.png' %}" alt="ddddd" />
- xyz

</div>
欢迎{{contact_name}}
你的用户名是{联系{u email}},你的内容是{{form_content}。 -xyz
但是图像没有显示在电子邮件中,并且显示错误


有人能帮我提供解决方案吗?

您提供的图像url是相对于您自己的网站的。 但是你要在谷歌上用这个相对的url获取它

它肯定会显示错误,因为在他们的服务器上找不到图像

尝试为图像提供绝对url。


我想那应该行。

你能给我举个例子吗你可以试试背景图片:url('http://www.example.com/images/contact.jfif)类似的东西。我在本地主机上做这件事,但它对我不起作用。是的,它对本地主机不起作用。它将只在网站是托管的情况下工作。因为一旦邮件被发送,你的站点的上下文就丢失了,对吗?