Detecting XHR on AppEngine WebFramework

I don’t know if it was lack of documentation (I doubt), but I was looking for a way to detect if a random view was being accessed from Ajax or not. This is a common practice in Django to avoid creating two different views when the purpose is the same, except for the request.

I even adapted the Django src code of the django.http HttpRequest to do an equivalent request.is_ajax()…

No need…

In your view just test is_xhr:

Leave a Reply

Your email address will not be published. Required fields are marked *