Testing AJAX Requests in Djangoby dave on 2009-05-08
Django has a really handy function on the request object that will determine if the request was an AJAX request (an XMLHttpRequest).
It'd be great if the Django client had a simple client.ajax request in addition to its client.post and client.get requests, but alas it doesn't. The tests can still be done however by changing the HTTP_X_REQUESTED_WITH header when sending your test requests.
From there its fairly straight forward to create your own .ajax wrapper if you'd like.
Now you have no excuse for not having complete tests for all of your XMLHttpRequests :).