[Python] Python Django custom 404 page not working

Discussão em 'Python' iniciado por Stack, Setembro 14, 2025.

  1. Stack

    Stack Membro Participativo

    I have essentially tried 2 solutions here. The first one:
    Created 404.HTML inside root templates directory which was supposed to be recognized by Django. By the way have defined it in settings.py:

    'DIRS': [BASE_DIR / 'templates'],


    The second solution I have tried:

    In urls.py:

    from django.conf.urls import handler404
    handler404 = 'pdfapp.views.not_found'


    in views.py:

    def not_found(request, exception):
    return render(request, 'partials/not_found.html', status = 404)


    None of these solutions have worked. Neither YouTube videos nor the other forms could help my case.

    Note: My DEBUG is set to False

    Continue reading...

Compartilhe esta Página