DEV Community

Connor Bode
Connor Bode

Posted on

HTMLField with Image Uploads in Django Admin

Well, this is mostly a reminder for myself on how to do this. The goal is to set up a generic "HTMLField" for models, which you can add photos to as well.

Here are the steps:

  1. Install django-tinymce4-lite
  2. Install django-filebrowser-no-grappelli
  3. In your settings.py, add X_FRAME_OPTIONS = 'sameorigin' (the filebrowser uses an iFrame which gets blocked by default)
  4. Let's say your MEDIA_ROOT is /media, and you want to upload files to /media/uploads. In settings.py, add FILEBROWSER_DIRECTORY = 'uploads/'. Then, make sure /media/uploads actually is a folder, or you will see an error.

Top comments (0)