DEV Community

Connor Bode
Connor Bode

Posted on

1

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)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay