【发布时间】:2020-07-24 07:16:58
【问题描述】:
我有一个 django 项目,用于在我想在模板中显示位置 iframe 的各个位置显示电影院的详细信息,并且我想在我的模型中保存 iframe 的完整 html 代码并将其分别渲染到模板中不同的剧院。
我已经创建了一个模型,我可以在其中获取剧院的细节。
models.py
class theater(models.Model):
name = models.CharField(max_length=200)
owner_name = models.CharField(max_length=200)
mobile = models.CharField(validators=[phone_regex],max_length=15,unique=True)
landline = models.CharField(max_length=15,null=True,blank=True,validators=[phone_regex])
email = models.EmailField(max_length=254, help_text="enter E-Mail address",null=True,blank=True)
website = models.URLField(max_length=300, help_text="enter website link",null=True,blank=True)
iframe_detail=models.TextField(max_length=5000)
在我的剧院的详细信息页面中,我可以渲染所有详细信息,但不能渲染 iframe 中的位置,下面是我的 template.html
theater_detail.html
<h1>Name: {{theater.name}}</h1><br>
<h1>Name: {{theater.mobile }}</h1><br>
<h1>Name: {{theater.email }}</h1><br>
<h1>Name: {{theater.website }}</h1><br>
<div class="w-100">
{{theater.iframe_detail|safe}}
</div>
我在模型中加载的 iframe 数据如下。 例如
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3806.9740157153647!2d78.46347561744385!3d17.413034599999996!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x3bcb975afb4afadd%3A0xf89ea8407df6c84!2sPrasads%20Multiplex!5e0!3m2!1sen!2sin!4v1595574993123!5m2!1sen!2sin" width="600" height="450" frameborder="0" style="border:0;" allowfullscreen="" aria-hidden="false" tabindex="0"></iframe>
【问题讨论】: