简体   繁体   中英

Whitenoise static file upload not working with DEBUG=False

I have a Django web app and I serve static files with Whitenoise. The problem is that I can't upload and get images when DEBUG=False . Everything work well with DEBUG=True but when I disable it, uploading is not working anymore but retrieving images works.

Here is my whitenoise configuration :

wsgi.py

from whitenoise.django import DjangoWhiteNoise
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
application = DjangoWhiteNoise(application)

and settings.py

MEDIA_ROOT = os.path.join(BASE_DIR, 'public/static/public/images')
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
STATIC_URL = '/static/'
STATIC_ROOT = 'public/static/'

Whitenoise isn't designed for serving media files. It scans the directory at startup, and assumes that the files will not change while the application runs.

See issue 32 for more information.

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