A
A
Alexander Lebedev2015-09-10 22:04:09
Django
Alexander Lebedev, 2015-09-10 22:04:09

How to pull images in Python-Django via media?

Good evening. I'm doing a test project on Django, I can't figure out why the pictures from the media folder are not pulled up. At the root of the project there is a media folder, it contains pictures. The settings says:

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

But the pictures don't load. I work through PyCharm, when I fill in MEDIA_ROOT, then the media folder itself pops up on the first letter, that is, there is no error with the path. What could be the problem?
5acfa00cfdb0410bb6f5b0fbb0f53806.png
0b7678dc06cd4a2483756e33a96a6753.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander, 2015-09-10
@syschel

Serving files uploaded by a user during development.
In production, static and media work through nginx / apache, without the participation of janga.
On the development server, under runserver, you need to specify additional settings in the urls.

V
Vladislav Sklyar, 2015-09-12
@VladSkliar

Add photo to profile page using thubnails?
Look at the answer, the same should be done for media.

S
scream4ik, 2015-09-12
@scream4ik

Based on your screenshot, you can see that when you call pictures from the media, a 500 error occurs. Open the image in the browser (for example 127.0.0.1/media/5.jpg) and see the problem

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question