Thursday, September 01, 2011

Django: Quickly testing an authenticated ajax


Make a authenticated post with the django test client and mark simulate an ajax post:
from django.test import Client
c = Client()
c.login(username='jjasinski', password='xxxx')
print c.post('/user/posts/1/',{},HTTP_X_REQUESTED_WITH='XMLHttpRequest')

No comments: