django-ckeditor / django-ckeditor

Django admin CKEditor integration.
BSD 3-Clause "New" or "Revised" License
2.39k stars 697 forks source link

Nested <script> for ckeditor-init.js file #768

Open eriktelepovsky opened 3 months ago

eriktelepovsky commented 3 months ago

Hello.

I installed django-ckeditor==6.7.1 and Django==4.2.11 but the CKEditor did not showed up. I noticed weird HTML code generated by CKEditorWidget:

<link href="/static/ckeditor/ckeditor.css" media="all" rel="stylesheet">
<script type="text/javascript" src="<script src="/static/ckeditor/ckeditor-init.js" data-ckeditor-basepath="/static/ckeditor/ckeditor/" id="ckeditor-init-script"></script>"></script>
<script type="text/javascript" src="/static/ckeditor/ckeditor/ckeditor.js"></script>

Notice nested <stript in the src for ckeditor-init.js

Any idea please?

When I change media() to this:

@property
    def media(self):
        return Media(
            css={"all": ["ckeditor/ckeditor.css"]},
            js=(
                # JS(
                #     "ckeditor/ckeditor-init.js",
                #     {
                #         "id": "ckeditor-init-script",
                #         "data-ckeditor-basepath": getattr(
                #             settings,
                #             "CKEDITOR_BASEPATH",
                #             None,
                #         )
                #                                   or static("ckeditor/ckeditor/"),
                #     },
                # ),
                "ckeditor/ckeditor-init.js",
                "ckeditor/ckeditor/ckeditor.js",
            ),
        )

it works perfectly fine. What's wrong with the JS()?

matthiask commented 3 months ago

This sounds a bit as if you're using django-js-asset<2 instead of the version which works with Django 4.1 or better?

Recent django-ckeditor versions depend on django-js-asset>=2.0, so I'm not sure what's going on.

matthiask commented 3 months ago

(... the CKEDITOR_BASEPATH thing is necessary when you're using ManifestStaticFilesStorage in production.)

eriktelepovsky commented 3 months ago

Yes, I have already found some issues and docs related to django-js-asset, CKEDITOR_BASEPATH and ManifestStaticFilesStorage but nothing helped.

I have most recent django-js-asset installed:

pip freeze|grep asset
django-js-asset==2.2.0

I already tried setting the CKEDITOR_BASEPATH to custom value. The path is changed, but the nested script in src is still present.

I don't use any Manifest static file storage.

And the issue is present on localhost as well.

matthiask commented 2 months ago

Are you maybe using a different template engine, Jinja2 or something?

It really sounds to me like a broken installation or something, I'm not sure. Sorry to not be of more help.

eriktelepovsky commented 1 month ago

No, I use default Django template engine :/