我正在尝试通过 ORM 在 django 中保存带有 Quill Field 的对象。我正在使用 PyPI 的 django-quill-editor 模块
这是模型:
from django_quill.fields import QuillField
class Product(models.Model):
name = models.CharField(max_length=100, blank=False, null=False)
description = QuillField(blank=False, null=False)
这是创建
Product
实例的代码:
product = Product.objects.create(
name='Sample Product',
description='{"delta":"{\"ops\":[{\"insert\":\"test desription\\n\\n\"}]}","html":"<p>test desription</p><p><br></p>"}',
)
product.save()
此操作失败并出现以下错误:
django_quill.quill.QuillParseError: Failed to parse value({"delta":"{"ops":[{"insert":"test desription\n\n"}]}","html":"<p>test desription</p><p><br></p>"})
我尝试提供纯文本值,得到了相同的结果。我从数据库中已有的另一行获取了 json。
知道如何通过 ORM 做到这一点吗?