Re: Returning JSON error when catching Django exception

2012-06-21 Thread Oleg Korsak
I'm not sure, but there must be a 404 template :) 22.06.2012 0:24 пользователь "Taras_96" написал: > Ok - I'm pretty sure that I should be returning 500s. Is there any way of > catching 404s and returning a JSON response for them as well? > > > On Friday, 22 June 2012 00:08:39 UTC+10, Kurtis wrot

Re: Returning JSON error when catching Django exception

2012-06-21 Thread Taras_96
Ok - I'm pretty sure that I should be returning 500s. Is there any way of catching 404s and returning a JSON response for them as well? On Friday, 22 June 2012 00:08:39 UTC+10, Kurtis wrote: > > I'm not sure if returning a response is any different in middleware than > it would be in a normal v

Re: Returning JSON error when catching Django exception

2012-06-21 Thread Kurtis Mullins
I'm not sure if returning a response is any different in middleware than it would be in a normal view. In that case: return HttpResponse(json_data, mimetype="application/json") On Thu, Jun 21, 2012 at 6:54 AM, Taras_96 wrote: > Does anyone have opinions on the best way of having middleware cat

Returning JSON error when catching Django exception

2012-06-21 Thread Taras_96
Does anyone have opinions on the best way of having middleware catch exceptions, and instead of rendering the error into a HTML template, to return a JSON object? Currently I have the middleware below that catches exceptions, and if it can find an extra user error message, puts that onto the