python – Why disabling DEBUG in Django does not recognize static files anymore


Why is it that when disabling DEBUG in Django , static files, such as CSS , images, or JS are no longer recognized? I disable it to bring up custom error pages, but disabling DEBUG all styles are removed. I would appreciate it very much, if you would tell me what I am missing, or what I am doing wrong.

In the file:

DEBUG = False


ALLOWED_HOSTS = ["localhost"]

In the file:

def handler404(request):
    return render(request,'error/404.html')


When you disable DEBUG , Django will stop handling static files. In that case your production server should do it.

In order to display your custom error page, you must create a template called 404.html and place it at the root of your template directory.

Here you find more detailed information:

Scroll to Top