djangocms-text-ckeditor icon indicating copy to clipboard operation
djangocms-text-ckeditor copied to clipboard

HTMLField in Django InlineAdmin causes TypeError when adding new record

Open lab360-ch opened this issue 9 months ago • 3 comments

I have a Model with an HTMLField in it. The Model with the HTMLField is used as StackedInline in the Django Admin.

When I add a new record, the CKEditor is not shown, instead only the Textarea is displayed, and I got a JavaScript Error: TypeError: Cannot read properties of undefined (reading 'replace').

image

The model Looks like this:

class CategoryTextSlide(models.Model):
    category = models.ForeignKey(
        Category,
        related_name="slides",
        verbose_name="Kategorie",
        on_delete=models.CASCADE,
    )

    text = HTMLField(
        verbose_name="Text",
        configuration="CKEDITOR_CATEGORY_TEASER_SLIDE_SETTINGS",
    )

    class Meta:
        verbose_name = "Kategorie Text Slide"
        verbose_name_plural = "Kategorien Text Slides"

The CKEditor settings like this:

CKEDITOR_CATEGORY_TEASER_SLIDE_SETTINGS = {
    "bodyClass": "category-teaser-slide",
    "toolbar_HTMLField": [
        ["Undo", "Redo"],
        ["Format", "RemoveFormat", "Bold", "Link"],
        ["Source", "Maximize"],
    ],
    "contentsCss": "/static/ckeditor.css",
    "format_tags": "h3;p",
}

And the Admin config like this:

class CategoryTextSlideAdmin(admin.StackedInline):
    model = CategoryTextSlide
    min_num = 1
    extra = 0

I use the following version:

  • Django: 4.25
  • Django CMS: 3.11.4
  • Django CMS CKEditor: 5.1.4
  • Python: 3.11.4

Thanks for helping.

Best regards

lab360-ch avatar Nov 01 '23 09:11 lab360-ch