Skip to content

ProseEditorField doesn't work with TranslatedField #41

@bitmensch

Description

@bitmensch

First, thanks for these great projects.

I am currently running the following versions in a Django project:

  • django-prose-editor==0.12.0
  • django-translated-fields==0.13.0

I have a model where I am trying to use ProseEditorField like this:

class Event(models.Model):
    description_prose = TranslatedField(
        ProseEditorField(
            _("description"),
            config={
                "extensions": {
                    "Bold": True,
                    "Italic": True,
                    "BulletList": True,
                    "Link": True,
                    "Heading": False,
                }
            },
            sanitize=True,
            blank=True,
        )
    )

When running Django dev server with this, it shows the following warning:

14:31:05 django | System check identified some issues:
14:31:05 django | 
14:31:05 django | WARNINGS:
14:31:05 django | core.Event.description_prose_de: (django_prose_editor.W001) This ProseEditorField is using the legacy configuration format which is deprecated and will be removed in a future version. Add the 'extensions' configuration explicitly to use the new configuration format.
14:31:05 django | core.Event.description_prose_de: (django_prose_editor.W004) This ProseEditorField doesn't have sanitization enabled. For security, it's recommended to enable sanitization.
14:31:05 django |       HINT: Consider using the newer extensions mechanism with sanitize=True for proper HTML sanitization that matches your editor capabilities.
14:31:05 django | core.Event.description_prose_en: (django_prose_editor.W001) This ProseEditorField is using the legacy configuration format which is deprecated and will be removed in a future version. Add the 'extensions' configuration explicitly to use the new configuration format.
14:31:05 django | core.Event.description_prose_en: (django_prose_editor.W004) This ProseEditorField doesn't have sanitization enabled. For security, it's recommended to enable sanitization.
14:31:05 django |       HINT: Consider using the newer extensions mechanism with sanitize=True for proper HTML sanitization that matches your editor capabilities.

Also when rendering these two fields in a form, it now shows the full editor toolbar with all buttons.

When I don't wrap this field in TranslatedField, the warning are gone and the editor toolbar doesn't contain all buttons as expected, e.g. Heading buttons are removed.

I noticed you're also the author of django-translated-fields, so maybe you have an idea/workaround how to get django-prose-editor to work with TranslatedField.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions