Django static files troubleshooting for production

BASE_DIR = Path(__file__).resolve().parent.parent

DEBUG = False

STATIC_URL = '/static/'

STATIC_ROOT = os.path.join(BASE_DIR, 'static')

INSTALLED_APPS has 'django.contrib.staticfiles'

This is how they're called in HTML
<img src="{% static 'capabilities-2.jpg' %}" class="img-fluid">

Displayed in my console:
[10/Sep/2022 17:39:50] "GET /css/index_styles.css HTTP/1.1" 404 179
[10/Sep/2022 17:39:50] "GET /js/scripts.js HTTP/1.1" 404 179
[10/Sep/2022 17:39:51] "GET /static/index/images/capabilities-2.jpg HTTP/1.1" 404 179
[10/Sep/2022 17:39:51] "GET /assets/favicon.ico HTTP/1.1" 404 179

Trying to transition from Dev to Production. I had the images working in development.

If I inspect the images (or lack of images) within a browser, the path is as follows:

Should be noted that I can't even see them when inspecting the source.

I tried adjusting the paths /static/capabilities-2.jpg to /static/index/images/capabilities-2.jpg as it is in my project but that still didn't work.

I'm running on Linode, Ubuntu 22.04. I like a lot about Django, but static files are being a huge PIMA.

The Django static file server is for use only during development. During production, use your webserver's static files capability:

Or if you're using a different one, look at the documentation and/or Google it.

Development environments are used for creating the project. The production environment is the server (or servers) on which your public website is hosted. For production, some of the choices:

How to store static media? For example, Amazon S3 or CloudFront.
Which OS and distribution? For example, Debian, Red Hat, or OpenBSD.
Which WSGI server? For example, Gunicorn or uWSGI.
Which webserver? For example, Apache or Nginx.
Which database? For example, PostgreSQL, MySQL, or Redis.
Which caching system? For example, Memcached or Redis.
Which process control and monitoring system? For example, Upstart,
Systemd, or Supervisord.

More information:

Back to Top