This question seems to be asked several time but I can not fix it.
I deployed a django app on production with DEBUG = False
. I set my allowed_hos
for BASE_DIR you need to a double dirname if your settings are not in the root but in /projectname/ folder :
settings.py
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
# for /static/root/favicon.ico
WHITENOISE_ROOT = os.path.join(BASE_DIR, 'staticfiles', 'root')
template.html
{% load staticfiles %}
app tree for this example:
annuaire
|-- /annuaire
|-- -- /settings.py
|-- /app
|-- /static/app/css/font.css