【发布时间】:2013-12-04 10:41:21
【问题描述】:
我有一个包含 description 字段的 django 模型:
class Product(models.Model):
name = models.CharField(max_length="125")
description = models.TextField()
class ProductForm(ModelForm):
class Meta:
model = Product
def __init__(self, *args, **kwargs):
super(ProductForm, self).__init__(*args, **kwargs)
self.fields['description'].widget.attrs = { 'placeholder':'Description', 'rows':'10'}
我将其渲染如下
<html>
<body>
{{form.name}}
{{form.description | linebreaks}}
</body>
</html>
所以使用上面的过滤器linebreaks,我能够以行格式获取数据,但现在我想在描述字段中提供一个 url(www.google.co.in),它应该是可点击的在前端product detail page
如何在前端的django描述字段中添加富文本格式?
【问题讨论】:
标签: django text-formatting field-description