Re: For discussion: JSON-aware views for error responses

2022-04-23 Thread 'Adam Johnson' via Django developers (Contributions to Django itself)
+1 from me - At least for 400, 500, and CSRF errors, send JSON (or empty response) > back instead of HTML if the request is xhr or has JSON headers > It's possible to detect requests for JSON with request.accepts() , which the previous PR from vanadium23 predates. There's no way to detect "if

Re: For discussion: JSON-aware views for error responses

2022-04-22 Thread vanadium23
I've done some work long ago. May be will help for someone. https://github.com/django/django/pull/8947 On Friday, 22 April 2022 at 08:53:56 UTC+3 Tobias Bengfort wrote: > +1 from me. > > On 14/04/2022 11.03, Ville Säävuori wrote: > > And to be clear, I understand we already have middleware APIs

Re: For discussion: JSON-aware views for error responses

2022-04-21 Thread Tobias Bengfort
+1 from me. On 14/04/2022 11.03, Ville Säävuori wrote: And to be clear, I understand we already have middleware APIs and various settings to handle this but my point is that I think handling this in Django core (even as an optional setting or middleware) would be most useful and right way to

Re: For discussion: JSON-aware views for error responses

2022-04-21 Thread Jacob Rief
I encountered this problem many times myself, so I'm +1 for this proposal. – Jacob -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send

For discussion: JSON-aware views for error responses

2022-04-21 Thread Ville Säävuori
Hello Django devs! I'm a long time Django user and nowadays work with sites where Django is mostly or only an API for the front end. I'm assuming this is not an exotic use case in 2022. One pain point I continue to come across over and over again is that Django by default only speaks