Running:Windows 7, Python 3.3. Django 1.6
Background: I'm created an app in Django using the REST framework, that accepts HTTP 'POST' requests with JSON descriptions of objects in the body and creates records in a SQL databse from those 'POST' requests. Most of the fields of such a database record are either integers, like numOfTests
or char fields like result
. These fields are deserialized into Django by the REST frameworks serializers.py
file, which (to my knowledge) translate the plain json string into an object in Django, who then saves them into the SQL database with the appropriate commands. But in each table record we also need to store a text file, as well as a screenshot, and I haven't figured out how to send these via HTTP and JSON.
Now I've read how to upload a image file via the Django shell, here in a previous question. But all of the data entries into the databse will be done by remote computers in my case, all via json in the body of the HTTP requests.
Question: So is there a way to serialize an image file or txt file, so the various remote computers at our office can post them via json to the django server?
Note: These HTTP POST
requests will be sent by scripts, in our case specifically every time a test finishes (python) it will send an http POST
to our server url with the details about it's completion. So there's no human being to manually enter the shell and such to save an image into Django.