Run python manage.py collectstatic
to combine all static files into one location and serve that in a professional HTTP server.
We need to configure some more settings in settings.py
before collectstatic
will work properly.
- STATIC_ROOT: which sets the absolute location of these collected files. All collected files will be placed under this folder.
- STATICFILES_DIRS: additional static files folders.
- also see STATICFILES_STORAGE.
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/
STATIC_URL = 'static/'
STATICFILES_DIRS = [ BASE_DIR / 'static']
STATIC_ROOT = BASE_DIR / 'staticfiles'