Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify a custom 404 view for Django using Class Based Views?

Using Django, you can override the default 404 page by doing this in the root urls.py:

handler404 = 'path.to.views.custom404'

How to do this when using Class based views? I can't figure it out and the documentation doesn't seem to say anything.

I've tried:

handler404 = 'path.to.view.Custom404.as_view'
like image 498
sid Avatar asked Mar 01 '13 02:03

sid


1 Answers

Never mind, I forgot to try this:

from path.to.view import Custom404
handler404 = Custom404.as_view()

Seems so simple now, it probably doesn't merit a question on StackOverflow.

like image 99
sid Avatar answered Sep 21 '22 19:09

sid