1👍
✅
I suggest you replace the standard Django 404 page TEMPORARILY.
In your virtual environment, the path for the Django 404 template can be found at (yourenvironmentname)/lib/python3.8/site-packages/django/views/templates
with the name technical_404.html and technical_500.html.
Replace the following files with your custom 404 and 500 pages.
👤Kwen
6👍
Just add this to your urls:
import django
def custom_page_not_found(request):
return django.views.defaults.page_not_found(request, None)
def custom_server_error(request):
return django.views.defaults.server_error(request)
urlpatterns = [
# .....
path("404/", custom_page_not_found),
path("500/", custom_server_error),
#.....
]
Update:
I didn’t mention it, but you need to have your custom 404.html
and 500.html
templates in your template directory.
Source:stackexchange.com