I think it's a fair point. The docs on HttpReqest.is_ajax() are
specifically discussing headers set from the client side, so I think
X-Requested-With would be more appropriate. This was discussed previously
and a more substantial change proposed:

https://groups.google.com/forum/#!searchin/django-developers/HTTP_X_REQUESTED_WITH/django-developers/Jvs3F79cY4Y/GW-S9GTYOKsJ

In fact, Collin Anderson submitted a proof of concept PR to this ticket
just ~2 days ago:

https://code.djangoproject.com/ticket/20147

Vignesh, I would follow this ticket and see if your concern could be
addressed through this implementation. If for whatever reason it doesn't go
through, you might consider filing a ticket
<https://docs.djangoproject.com/en/1.9/internals/contributing/bugs-and-features/>
and pull request (if the ticket is accepted) for a small improvement to the
documentation -- to change the header name referenced as you suggested
and/or point people to the section of the docs that talks about how headers
and META keys are different (
https://docs.djangoproject.com/en/1.9/ref/request-response/#django.http.HttpRequest.META
).

Cheers,
Tobias

On Mon, Jun 20, 2016 at 9:32 AM, Paulo Gabriel Poiati <
[email protected]> wrote:

> That is because the documentation is referring to the WSGI envrion
> dictionary (and thus the CGI spec). This is how the translation from the
> client to the server works: X-My-Header becomes HTTP_X_MY_HEADER. It isn't
> wrong IMO.
>
> On Sun, Jun 5, 2016 at 8:52 AM Vignesh Tnj <[email protected]> wrote:
>
>> https://docs.djangoproject.com/en/1.9/ref/request-response/
>>
>> " HttpRequest.is_ajax()[source]
>> <https://docs.djangoproject.com/en/1.9/_modules/django/http/request/#HttpRequest.is_ajax>
>> ¶
>> <https://docs.djangoproject.com/en/1.9/ref/request-response/#django.http.HttpRequest.is_ajax>
>>
>> Returns True if the request was made via an XMLHttpRequest, by checking
>> the HTTP_X_REQUESTED_WITH header for the string'XMLHttpRequest'. Most
>> modern JavaScript libraries send this header. If you write your own
>> XMLHttpRequest call (on the browser side), you’ll have to set this header
>> manually if you want is_ajax() to work. "
>>
>>
>> if we set ,  xhttp.setRequestHeader('HTTP_X_REQUESTED_WITH',
>> 'XMLHttpRequest');     as said in doc
>>
>> request.is_ajax()   return False
>>
>> -------------------------------
>>
>> if we set , http.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
>>
>> request.is_ajax()   return true
>>
>> --
>> 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 [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at https://groups.google.com/group/django-developers.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-developers/7a88b8d8-b15f-4377-8264-e94130ad041e%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-developers/7a88b8d8-b15f-4377-8264-e94130ad041e%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> *[]'s*
> *Paulo Poiati*
> blog.paulopoiati.com
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/CABqSV%3DJNiAPpR%3DW5kZa5-gm2Kmn%2BYJV2G1dxBoiBCGtJGN8-hQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-developers/CABqSV%3DJNiAPpR%3DW5kZa5-gm2Kmn%2BYJV2G1dxBoiBCGtJGN8-hQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 


*Tobias McNulty*Chief Executive Officer

[email protected]
www.caktusgroup.com

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAMGFDKQ2eOxYW-21RZ%3Dfx%2BC%3DxWPm0gV9VByq49UHQVUxR-mNNQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to