xxxxxxxxxx
from django.shortcuts import get_object_or_404
def my_view(request):
obj = get_object_or_404(MyModel, pk=1)
xxxxxxxxxx
You dont need to do anything fancy, just create 404.html file in your templates. Go to settings.py and set DEBUG = False, ALLOWED_HOSTS = ["*"] It will automaticaly overwrite the deafualt.