1STATICFILES_DIRS = [
2 BASE_DIR / "static",
3 '/var/www/static/',
4]
5{% load static %}
6<img src="{% static 'my_app/example.jpg' %}" alt="My image">
1To deploy a production server, you need to set 3 things
2
3deactivate the DEBUG configuration:
4DEBUG = False <---------------
5
6This disable all extra function for development.
7
8define a static root directory in the settings file:
9STATIC_ROOT = '/this/is/a/path/to/statics' <--------------
10
11This, indicate where all the static files should be saved.
12
13run the command to collect all static files:
14python manage.py collectstatic <------------
15
16This saves all statics files in the directory configured by STATIC_ROOT
17
18The official documentation for deployment: https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/#static-root-and-static-url