Unfortunately it's true. Django-ckeditor does not provide any built-in solution for this problem. Information about the downloaded files is not stored anywhere.
If you want to save them - you have to do it yourself!
Create the appropriate data model using the overridden deletion method (or use any of the ready-made smart fields that can handle file deletion for you, Django delete FileField ):
from django.db import models class UploadedFile(models.Model): uploaded_file = models.FileField(upload_to=u"storage/") uploaded_at = models.DateField(editable=False, auto_now_add=True) def __str__(self): return os.path.basename(self.uploaded_file.path) def url(self): return self.uploaded_file.url def delete(self, *args, **kwargs): file_storage, file_path = self.uploaded_file.storage, self.uploaded_file.path super(UploadedFile, self).delete(*args, **kwargs) file_storage.delete(file_path)
Provide your own implementation of the βdownloadβ (and optional βviewβ), which will be used to remember transactions:
from django.conf import settings from django.contrib.admin.views.decorators import staff_member_required from django.views.decorators.cache import never_cache from django.views.decorators.csrf import csrf_exempt from ckeditor_uploader.views import upload, browse from .models import UploadedFile import re @staff_member_required @csrf_exempt def ckeditor_upload_wrapper(request, *args, **kwargs): response = upload(request, *args, **kwargs) if b"Invalid" not in response.content: try: matched_regex = re.search("callFunction\(\d, '(.*)'\);", str(response.content)) file_location = matched_regex.group(1).lstrip(settings.MEDIA_URL) UploadedFile(uploaded_file=file_location).save() except Exception: pass return response @staff_member_required @csrf_exempt @never_cache def ckeditor_browse_wrapper(request, *args, **kwargs): return browse(request, *args, **kwargs)
Change the default redirects in urls.py :
... from app.views import ckeditor_upload_wrapper, ckeditor_browse_wrapper urlpatterns = [ url(r'^admin/', admin.site.urls),
and thatβs all ... Now, if you register a new UploadedFile model, you will provide the ability to view, search and delete any uploaded images directly from the Django admin panel.
(This solution was implemented for Django 1.10 with the extension django-ckeditor 5.3)