- Author:
- mallipeddi
- Posted:
- January 30, 2008
- Language:
- Python
- Version:
- .96
- 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
- Template tag - list punctuation for a list of items by shapiromatron 10 months, 2 weeks ago
- JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 10 months, 3 weeks ago
- Serializer factory with Django Rest Framework by julio 1 year, 5 months ago
- Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 6 months ago
- Help text hyperlinks by sa2812 1 year, 6 months ago
Comments
how about to email error that was happened? ;)
#
Please login first before commenting.