Django static files in deployment DEBUG = FALSE

Good afternoon, I’ve been having problems with deployment. Specifically when DEBUG = FALSE (whenever DEBUG = TRUE it’s loading all static files without problem). I can’t seem to find the problem, any guidance would be helpfull.

All apps are shown in the image below, taller is the main app. The directory static and staticfiles where created using collectstatic (they have the same files).
django_1

In settings, the STATIC_URL, STATIC_ROOT and STATICFILES_DIRS are defined as:

django_2

I add the static(settings…) to urlpatterns only in the urls of the main app taller.

django_3.

Whenever I run it with DEBUG = FALSE, I get the 404 error as show below:

Otherwise with DEBUG = TRUE works fine.

What seems to be off?

Review the docs at:

Also, you don’t mention how you’re trying to run your Django app in your deployment environment, so I’ll just emphasize this particular lines in the docs for runserver:

DO NOT USE THIS SERVER IN A PRODUCTION SETTING.

If you’re not using runserver, then it would help if you describe how you’re running your application and how you have it configured to serve the static files. Also note that in most common situations, you do not want your STATIC_ROOT to be anywhere within your project directory.

Django not serving your static files in debug False.
you need to serve it with web server like nginx, apache or etc.

debug False used in production environment.
in production environment you used another tools to run django.

I personally set up my project in production using Gunicorn/Uvicorn and Nginx.
Gunicorn is a tool to run django from your project wsgi (i run my project in localhost). Nginx used as proxy from internet to my localhost. Static file is not yet served with this set up. you need to tell nginx to serve your static files folder.