0

I'm trying to install TinyMCE to my django project for blog posts, I have the initial content block working but It isn't allowing me to upload images with the following errors:

Forbidden (CSRF token missing.): /admin/mhpapp/testmodel/add/static/images/images

I have the app added in my settings.py

Settings.py:

urlpatterns = [
    path('tinymce/', include('tinymce.urls')),

TINYMCE_DEFAULT_CONFIG = {
    "height": "320px",
    "width": "960px",
    "menubar": "file edit view insert format tools table help",
    "plugins": "advlist autolink lists link image charmap print preview anchor searchreplace visualblocks code "
    "fullscreen insertdatetime media table paste code help wordcount spellchecker",
    "toolbar": "undo redo | bold italic underline strikethrough | fontselect fontsizeselect formatselect | alignleft "
    "aligncenter alignright alignjustify | outdent indent |  numlist bullist checklist | forecolor "
    "backcolor casechange permanentpen formatpainter removeformat | pagebreak | charmap emoticons | "
    "fullscreen  preview save print | insertfile image media pageembed template link anchor codesample | "
    "a11ycheck ltr rtl | showcomments addcomment code",
    "custom_undo_redo_levels": 10,
    "images_upload_url": 'static/images/images',
    "images_upload_handler": "tinymce_image_upload_handler"

}

TINYMCE_EXTRA_MEDIA = {
    'css': {
        'all': [
        ],
    },
    'js': [
        "https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.js",
        "admin/js/tinymce-upload.js",
    ], 
}

I am currently testing on local server but would also like this to work on my production server that I have hosted on my own ubuntu VPS usinh nginx

Any help would be greatly appreciated.

David Henson
  • 355
  • 1
  • 10
  • Just a general question, if you're trying to build a blog, why not use a CMS? For example, Wagtail is great. – Vincent Jan 18 '23 at 21:52
  • I'm very new to coding, So I basically just built a website from scratch which if an image gallery for my fathers photography, he also wanted me to add a blog feature for him. I wasn't aware of another ways other than building it my self. – David Henson Jan 18 '23 at 22:06
  • Ah okay, fair enough! Wagtail is build on top of Python/Django and is therefore very customizable. Each page and component on that page can be made by yourself. I'd advise you to take a look at their toturial and see for yourself. I find their documentation very good. – Vincent Jan 18 '23 at 22:17
  • @Vincent , does wagtail only implement into a whole site? Or can you make it work with only one page on your website? – David Henson Jan 19 '23 at 07:29
  • I'm not quite sure if I understand you correctly, but you can have wagtail next to normal Django views. You could for example serve all wagtail page urls from /blog but have a normal django view as a homepage served from / – Vincent Jan 19 '23 at 10:25
  • That's exactly what I mean... I think.. ha. Sorry like i said I'm very new. I'll have a deeper look into it later as I'd only want to modify my blog page and keep everything else as it is. At the moment the blogs look very basic and I can't see to be ae to get ckeditor5 to show all the tools that are meant to be available – David Henson Jan 19 '23 at 16:27
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/251268/discussion-between-vincent-and-david-henson). – Vincent Jan 19 '23 at 16:45

0 Answers0