LeeHanYeong / django-quill-editor

django-quill-editor makes Quill.js easy to use on Django Forms and admin sites
https://django-quill-editor.readthedocs.io
MIT License
202 stars 49 forks source link

django quill editor with django rest framework #133

Open valen-xx opened 2 weeks ago

valen-xx commented 2 weeks ago

Internal Server Error: /blog/post/create Traceback (most recent call last): File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\django_quill\quill.py", line 24, in init self.delta = json_data["delta"]


TypeError: string indices must be integers, not 'str'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\django\core\handlers\exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\django\core\handlers\base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\django\views\decorators\csrf.py", line 65, in _view_wrapper
    return view_func(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\django\views\generic\base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\rest_framework\views.py", line 509, in dispatch
    response = self.handle_exception(exc)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\rest_framework\views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\rest_framework\views.py", line 480, in raise_uncaught_exception
    raise exc
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\rest_framework\views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\valen\OneDrive\Bureau\playlist\backend\blog\views.py", line 43, in post
    serializers.save()
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\rest_framework\serializers.py", line 208, in save
    self.instance = self.create(validated_data)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\rest_framework\serializers.py", line 989, in create
    instance = ModelClass._default_manager.create(**validated_data)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\django\db\models\manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\django\db\models\query.py", line 679, in create
    obj.save(force_insert=True, using=self.db)
  File "C:\Users\valen\OneDrive\Bureau\playlist\backend\blog\models.py", line 42, in save
    super().save(*args, **kwargs)
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\django\db\models\base.py", line 891, in save
    self.save_base(
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\django\db\models\base.py", line 997, in save_base
    updated = self._save_table(
              ^^^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\django\db\models\base.py", line 1160, in _save_table
    results = self._do_insert(
              ^^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\django\db\models\base.py", line 1201, in _do_insert
    return manager._insert(
           ^^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\django\db\models\manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\django\db\models\query.py", line 1847, in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\django\db\models\sql\compiler.py", line 1835, in execute_sql
    for sql, params in self.as_sql():
                       ^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\django\db\models\sql\compiler.py", line 1760, in as_sql
    self.prepare_value(field, self.pre_save_val(field, obj))
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\django\db\models\sql\compiler.py", line 1699, in prepare_value
    return field.get_db_prep_save(value, connection=self.connection)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\django\db\models\fields\__init__.py", line 1008, in get_db_prep_save
    return self.get_db_prep_value(value, connection=connection, prepared=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\django\db\models\fields\__init__.py", line 1001, in get_db_prep_value
    value = self.get_prep_value(value)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\django_quill\fields.py", line 145, in get_prep_value
    value = super().get_prep_value(value)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\django\db\models\fields\__init__.py", line 2491, in get_prep_value
    return self.to_python(value)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\django_quill\fields.py", line 139, in to_python
    return value.quill
           ^^^^^^^^^^^
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\django_quill\fields.py", line 41, in _get_quill
    self._quill = Quill(self.json_string)
                  ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\valen\AppData\Roaming\Python\Python312\site-packages\django_quill\quill.py", line 28, in __init__
    raise QuillParseError(json_string)
django_quill.quill.QuillParseError: Failed to parse value("<p>hhehehehhe</p>")
[13/Nov/2024 20:34:35] "POST /blog/post/create HTTP/1.1" 500 208443