Search code examples
djangotestingclient

Django test client post data is empty


I have a very simply application where I have to create a simple post request using a django test client.

userFrom = Client()
userFrom.login(username="admin1",password=test_password)
data = {"some":"data"}
responseNew = userFrom.post("/foo/too/",simplejson.dumps(data),content_type="application/json")

When I check the post request at the view of "/foo/too/" the post dictionary is empty.

I have checked the following question. It does not work. I am using Django 1.5.

Post dictionary is empty


Solution

  • You can try something like:

    responseNew = userFrom.post("/foo/too/", data)