django-quill-editor icon indicating copy to clipboard operation
django-quill-editor copied to clipboard

Integrate with Django Rest Framework

Open Enzodtz opened this issue 2 years ago • 3 comments

Hey!

I was trying to use the editor with DRF, but when DRF serializes the field, it just calls str method, which returns that default python str for classes. If we instead return the delta, it will be possible to integrate with the serializer just fine.

I will open a PR to do so.

Enzodtz avatar Oct 15 '22 05:10 Enzodtz

PR Opened: #99

Enzodtz avatar Oct 15 '22 05:10 Enzodtz

What's the status on this, I need to use the QuillField in my App via an API but there seems to be no easy way to achieve this out of the box.

scroogeT avatar Jan 11 '23 08:01 scroogeT

@scroogeT i had to override the to_representation method of rest framework serializer class to get instance.content.delta like so.

def to_representation(self, instance):
        resp = super().to_representation(instance)
        resp["content"] = instance.content.delta
        return resp

content is the atrribute with quill field...

goodnewsj62 avatar Jan 28 '23 22:01 goodnewsj62