+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 the request is xhr" - we removed
request.is_ajax because it only detected requests made with jQuery and some
other libraries.


> - Make it easy to override the JSON like we can do with HTML
>

I think we don't need to add new extension points. If you want custom JSON
or HTML, you can provide your own views. These views can always "return
custom JSON *or* call Django's built-in views".

On Sat, Apr 23, 2022 at 6:16 AM vanadium23 <chernoffi...@gmail.com> wrote:

> 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 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 do this for the community.
>>
>> Can you provide some examples? I support the general idea, but having
>> some concrete APIs to discuss might be helpful.
>>
>> thanks
>> tobias
>>
> --
> 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 an
> email to django-developers+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/744c3b96-4c42-4eac-a451-5c6f6da446fdn%40googlegroups.com
> <https://groups.google.com/d/msgid/django-developers/744c3b96-4c42-4eac-a451-5c6f6da446fdn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAMyDDM0inQhY3q6oVZEV-ELmSYHKtHrHm53wJ2OQ68mq1JTpew%40mail.gmail.com.
  • For... Ville Säävuori
    • ... Jacob Rief
    • ... Tobias Bengfort
      • ... vanadium23
        • ... 'Adam Johnson' via Django developers (Contributions to Django itself)

Reply via email to