Login

A custom 500 handler which is AJAX-aware

Author:
mallipeddi
Posted:
January 30, 2008
Language:
Python
Version:
.96
Tags:
ajax 500 handler httprequest
Score:
1 (after 1 ratings)

The default 500 handler does not take into consideration if the HTTP request made is an XMLHttpRequest. If it's an XHR, then it may not be a good idea to send back your default 500 HTML page.

To use this custom 500 handler, just add the following to your urls.py:

handler500 = 'my_project.my_app.views.my_500'
1
2
3
4
5
def my_500(request):
    if request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest':
        return HttpResponse("")
    else:
        return render_to_response("500.html",{},context_instance=RequestContext(request))

More like this

  1. Use MEDIA_URL in 500 error page by bthomas 6 years, 6 months ago
  2. Extend simplejson to understand closures, functors, generators and iterators by ElfSternberg 6 years ago
  3. Upload progress handler using cache framework by ebartels 7 years, 1 month ago
  4. upload handler decorators by Rozza 6 years, 10 months ago
  5. Super User Conditional Page Exception Reporting by zbyte64 6 years, 10 months ago

Comments

buriy (on January 31, 2008):

how about to email error that was happened? ;)

#

Please login first before commenting.