3

I had a textField in my model before. Now I want to upgrade it to a rich text field using Django Quill Editor. But I am unable the migrate the old data.

I tried to just copy the text inside the quillfield in a management command but it gives QuillParseError then I looked the databse and figured that the fields are stored like:

{"delta":"{\"ops\":[{\"insert\":\"text\\n\"}]}","html":"<p>text</p>"}

in the database. I kept the delta empty and only filled the html. the html appeared in the database but not in the admin. I then tried to fabricate the ops. without filling the html and that failed too. I can only think of fabricating the whole object but that would be a bit difficult. I was wondering if there is any sane way to migrate html/text data to quillfield or any other richtext editor.

user4157124
  • 2,809
  • 13
  • 27
  • 42
yukashima huksay
  • 5,834
  • 7
  • 45
  • 78

1 Answers1

0

I have added this value as a default for the new fields in old models and it worked:

default='{"delta":{"ops":[{"insert":"test"}]},"html":"<p>test</p>"}'

Lina Shyshova
  • 546
  • 5
  • 12
  • Thank you. But when the text becomes more complex it won't work. We ended up moving to tinymce and it has been working great so far. – yukashima huksay Mar 13 '21 at 13:26