froala / django-froala-editor

Package to integrate Froala WYSIWYG HTML rich text editor with Django.
https://froala.com/wysiwyg-editor
283 stars 72 forks source link

json encoding of option should use DjangoJSONEncoder #77

Open tisdall opened 4 years ago

tisdall commented 4 years ago

https://github.com/froala/django-froala-editor/blob/e70b402beab6611ad4d5a4ed46cb6ead1c2eec3d/froala_editor/widgets.py#L56

The json encoding should use django.core.serializers.json.DjangoJSONEncoder so lazy components from settings can properly be evaluated.

For example, I'm trying to set imageManagerLoadURL using reverse_lazy. However, the default encoding gives a traceback when it encounters the reverse_lazy. If it used DjangoJSONEncoder then it would work properly.

from django.core.serializers.json import DjangoJSONEncoder
json_options = json.dumps(options, cls=DjangoJSONEncoder)