Answer the question
In order to leave comments, you need to log in
Is it possible to put django static files directly into STATIC_ROOT?
Good evening.
I have a question that may be silly, but really tormenting me: all the manuals for static files in Django say that you need to use the collectstatic command to collect files in the folder specified in the settings in the STATIC_ROOT variable.
I don't understand where Django collects these files from. Aren't all the files immediately in some shared folder? I, maybe in my stupidity, put all the files in the media folder, neatly, on the shelves. Then I used MEDIA_ROOT, MEDIA_URL and everything worked. And now, after a break, I decided to figure out if this is correct. What is the fundamental difference between STATIC and MEDIA?
Answer the question
In order to leave comments, you need to log in
STATIC_ROOT - directory where non-changeable files are stored. As a rule, this is the layout of the design, verification keys, and so on. The fact that the site developer has kept forever.
MEDIA_ROOT - Directory of user files. What users fill in (avatars, text files / archives), what the engine can generate itself (for example, the script steals pictures from another site and stores them here).
I don't understand where Django collects these files from.
import os
PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
MEDIA_ROOT = os.path.join(PROJECT_PATH, "media")
MEDIA_URL = '/media/'
STATIC_ROOT = os.path.join(PROJECT_PATH, "static")
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(PROJECT_PATH, "dev_static"),
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question