Question:
How to populate Django Quill Field from ORM

Problem

I am trying to save an object with a Quill Field in Django via the ORM. I am using the >django-quill-editor module from PyPI


Here is the model:


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)


Here is the code for creating a Product instance:


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()


This fails with the following error:


django_quill.quill.QuillParseError: Failed to parse value({"delta":"{"ops":[{"insert":"test desription\n\n"}]}","html":"<p>test desription</p><p><br></p>"})


I have tried supplying a plain text value and I get the same result. I got the JSON from another row that is already in the database.


Any idea how to do this via the ORM?


Solution

This might be useful, please have a look: >https://github.com/LeeHanYeong/django-quill-editor/issues/13#issuecomment-776863989


Answered by: >M Waqar Anwar

Credit: >StackOverflow


Blog Links

>Sorting the restframework in Django

>Ways to access instances of models in view in order to save both forms at once in Django

>What makes index.html have such kind of name in Django?

>Fix Module Not Found during Deployment- Django

>Creating a Django with existing directories, files, etc.?

>How to Read a CSV file with PHP using cURL?


Nisha Patel

Nisha Patel

Submit
0 Answers