I
I
Ilya2020-11-07 05:38:02
Django
Ilya, 2020-11-07 05:38:02

How to make the correct path to the folder with the image?

Folder for uploaded images:

E:\django\kuluars\media\uploads

The settings file says:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static")
MEDIA_URL = '/media/uploads/'
MEDIA_ROOT = os.path.join(BASE_DIR, "media/uploads")

CKEDITOR_FILENAME_GENERATOR = 'utils.get_filename'
CKEDITOR_UPLOAD_PATH = MEDIA_ROOT
CKEDITOR_IMAGE_BACKEND = 'pillow'

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, os.path.join(BASE_DIR, "dev_static")),
]

utils.get_filename
def get_filename(filename):
    return filename.upper()

You add an image using ckeditor and you get the path:
127.0.0.1:8000/media/uploads/E%3A/django/kuluars/media/uploads/IMGP1503_spelta_b5b2d3fe.jpg

You simply write:
127.0.0.1:8000/media/uploads/IMGP1503_spelta_b5b2d3fe.jpg

And everything works great.

I understand that
E%3A/django/kuluars/media/uploads/

this is the path to the folder
E:\django\kuluars\media\uploads

Why does ckeditor add this path and how can I remove it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question