简体   繁体   中英

serve static and media files in django when debug=False

I want to publish my django project but when is change my settings.py "debug = False" static files are not loaded ! here is my settings.py

MEDIA_URL = '/media_files/'
STATIC_URL = '/static_files/'

MEDIA_ROOT = '/home/domain/public_html/static_cdn/media_root'
STATIC_ROOT = '/home/domain/public_html/static_cdn/static_root'

also I used "python manage.py collectstatic" command and it created folder in public_html

i tried many ways but this is worked for me: for Media files Create a symlink of media folder to public_html in terminal:

$ ln -s ~/project_path/media/ public_html/media

for static files make symlink in terminal or just copy them to public_html folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM