Answer the question
In order to leave comments, you need to log in
Why doesn't static work after uploading to hosting?
What's wrong here?
STATIC_URL = '/static/'
# STATIC_ROOT = 'static'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
os.path.join(BASE_DIR, "meccano_print/static"),
os.path.join(BASE_DIR, "prints/static"),
os.path.join(BASE_DIR, "zels/static"),
]
Answer the question
In order to leave comments, you need to log in
1. You need to define STATIC_ROOT
- Django copies files from STATICFILES_DIRS
.
2. Decide in which directory you will keep the general project statics that are not related to any particular application. Write it in STATICFILES_DIRS
.
3. No need to point to STATICFILES_DIRS
specific application directories - Django by default collects STATIC_ROOT
everything it finds in directories static
inside applications.
So the configuration could be like this:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static") # Изначально пустой каталог, куда Django соберёт всё при выполнении manage.py collectstatic
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static_dev"), # Каталог, куда вам нужно складывать статику проекта, не относящуюся к конкретному приложению
]
runserver
, then you need to set up the distribution of statics in development mode . And don't forget to run manage.py collectstatic
. Good luck!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question