Answer the question
In order to leave comments, you need to log in
What is the difference between STATIC_ROOT, STATIC_URL, MEDIA_ROOT, MEDIA_URL and the like?
Well, actually the essence of the question has already been stated above, what is the difference between STATIC_ROOT, STATIC_URL, MEDIA_ROOT, MEDIA_URL?
I read the documentation and see a fig, I can’t understand
. In general, the task is to make a slider with downloadable images from the admin panel, how to specify the path to this downloaded image in the template? Is it possible somehow through 'django.core.context_processors.request'?
model.py
class Slide(models.Model):
image = models.ImageField(u'Изображение', upload_to='static/slides')
header = models.CharField(u'Заголовок', max_length=120, blank=False)
caption = models.CharField(u'Описание', max_length=250, blank=False)
Answer the question
In order to leave comments, you need to log in
STATIC_ROOT - storage location on disk for your static files (js, styles, images)
STATIC_URL - url prefix to these files
MEDIA_ROOT - storage location on disk for files uploaded by users
MEDIA_URL - url prefix to these files
MEDIA_ROOT stores files uploaded by the user. Or which were generated as a result of the scripts. And STATIC_ROOT is designed to store "non-dynamic" files that do not change on their own in the process of work and are part of the project. Styles, scripts, design pictures, fonts.
And MEDIA_URL and STATIC_URL are urls where directories for media files and statics are available, respectively
. As for the slider: uploaded files will go to MEDIA_ROOT. And you can get the URL of each frame like this:<img src="{{ slide.image.url }}">
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question