#25045: Django 1.8.2 handler404 and handler500 no longer work
------------------------------+--------------------------------------
     Reporter:  simon9999     |                    Owner:  nobody
         Type:  Bug           |                   Status:  new
    Component:  Core (Other)  |                  Version:  1.8
     Severity:  Normal        |               Resolution:
     Keywords:  handler404    |             Triage Stage:  Unreviewed
    Has patch:  0             |      Needs documentation:  0
  Needs tests:  0             |  Patch needs improvement:  0
Easy pickings:  0             |                    UI/UX:  0
------------------------------+--------------------------------------
Changes (by simon9999):

 * needs_better_patch:   => 0
 * needs_tests:   => 0
 * needs_docs:   => 0


Old description:

> I've been testing with DEBUG=False under 'python manage.py runserver'.
> As per the dox, I have added into my ROOT url file, the required
> overrides:
>

> {{{
> from django.conf.urls import *
> from django.contrib import admin
> from django.http import HttpResponse
>
> handler404 = 'urls.custom_handler'
> handler500 = 'urls.custom_handler'
>
> urlpatterns = [
>     url(r'^apikey/', include('apikey.urls', namespace='apikey')),
>     url(r'^admin/', include(admin.site.urls)),
> ]
>
> def custom_handler(request):
>     print '---->>>> got to here!'
>     raise Exception
>     return HttpResponse('<h1>Boo! - Page not found</h1>')
>

> }}}
>

> I have created both the default 404.html and 500.html templates in my
> apikey/templates directory and updated the site settings file to reflect
> this
> and I can confirm that this default 404.html and 500.html files are
> indeed getting rendered, but '''not''' by my routine.
>
> My custom handler never, '''ever''' fires when a 404 or 500 is raised.
>
> I am at a loss as to why this has stopped working and I have been
> searching both the tickets DB and the net for a solution so it may well
> be a bug.

New description:

 I've been testing with DEBUG=False under 'python manage.py runserver'.
 As per the dox, I have added into my ROOT url file, the required
 overrides:


 {{{
 from django.conf.urls import *
 from django.contrib import admin
 from django.http import HttpResponse

 handler404 = 'urls.custom_handler'
 handler500 = 'urls.custom_handler'

 urlpatterns = [
     url(r'^apikey/', include('apikey.urls', namespace='apikey')),
     url(r'^admin/', include(admin.site.urls)),
 ]

 def custom_handler(request, template_name='404.html'):
     print '---->>>> got to here!'
     raise Exception
     return HttpResponse('<h1>Boo! - Page not found</h1>')


 }}}


 I have created both the default 404.html and 500.html templates in my
 apikey/templates directory and updated the site settings file to reflect
 this
 and I can confirm that this default 404.html and 500.html files are indeed
 getting rendered, but '''not''' by my routine.

 My custom handler never, '''ever''' fires when a 404 or 500 is raised.

 I am at a loss as to why this has stopped working and I have been
 searching both the tickets DB and the net for a solution so it may well be
 a bug.

--

Comment:

 pasted in the wrong custom_handler() - now corrected

--
Ticket URL: <https://code.djangoproject.com/ticket/25045#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.68760d2c770ee0339e2132c887e30da4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to