1

I am trying to use custom template on page_not_found default handle

Inside urls.py

from django.views.defaults import page_not_found

handler404 = page_not_found(request, None, "pages/custom/404.html")

page_not found method requires request, exception and template. So how can i get the request object. I know the alternative for using it inside views.py

1
  • 2
    There is no need to do this. Just put your 404.html in the base templates directory and it will be used automatically. Commented Mar 9, 2018 at 8:24

1 Answer 1

1

You should define handler404 with a function, not return value of the function.

from functools import partial

handler404 = partial(page_not_found, template_name='pages/custom/404.html')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.