I'm writing a test for my AJAX view which should process some text data and image. Is it possible using the Django Client or I should use Requests library for this test?
with open(somestring, "rb") as photo:
updated_data = {
'first_name': "updatedname",
"last_name": "updatedlastname",
"birth_date": str(date(2020, 5, 11).isoformat()),
"email": "updateduser@example.com",
"skype": "updateduser",
# '"blah-blah" is not JSON serializable' raised
# "photo": photo
}
data = json.dumps(updated_data)
# data is a string
# with getRawImage() as photo:
# data.update({"photo": photo})
self.client.post('/',
data,
content_type='application/json',
HTTP_X_REQUESTED_WITH='XMLHttpRequest'
)