Hello @Nick Mol !
It's not recommended to leave out STATICFILES_STORAGE in your Django app, especially in a production environment. When DEBUG is set to True, Django serves static files itself, but in production (when DEBUG is set to False), you should use a production-ready static files solution like Whitenoise or Django's built-in collectstatic command to serve static files efficiently. If disabling STATICFILES_STORAGE makes it work, it might indicate an issue with your static files configuration. Review your static files setup, check file permissions, and make sure your static files are correctly collected and served with Whitenoise or another suitable storage backend.
EXAMPLE :
To collect static files in Django, follow these steps:
- Ensure that your
STATIC_URLandSTATIC_ROOTsettings are correctly configured in your Django project's settings.
# settings.py
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
- Run the following command to collect static files:
python manage.py collectstatic
This command will gather all static files from your apps into the directory specified by STATIC_ROOT.
- Make sure your web server (e.g., Gunicorn or uWSGI) serves these static files correctly in production. You may use a middleware like Whitenoise or configure your web server to serve static files.
By following these steps, your Django app will collect and serve static files in a production environment while DEBUG is set to False.
Also , Verify that your ALLOWED_HOSTS setting includes the correct domain names or IP addresses.
I hope this helps!
The answer or portions of it may have been assisted by AI Source: ChatGPT Subscription
Kindly mark the answer as Accepted and Upvote in case it helped!
Regards