0

I have uploaded some images within the CKEditor, and uploaded images are stored on the server, when I delete the image on the editor, the image stored on the server is not deleted.

Django 2.2, python 3.7, postgresql.

my question: can I set it on ckeditor or on models?

if can how to create a condition when the upload image is automatically deleted when removed on ckeditor?

1 Answers1

0

You can create an api that delete the image on the server when user delete it on the editor.

Define the url like:

url_patterns = [
    path('delete-image', delete_image, name='delete_image'),
]

The api view where you delete the image on server:

@api_view(['POST'])
def delete_image(request):
   # Delete image

jQuery scripts:

    <when image is deleted on editor>{
       $.post(url, data, function(data, status){
       })
    }
Rin Nguyen
  • 405
  • 4
  • 11