Forgive me if this is a little newbie question, I started learning Django yesterday, and I try not to get into bad habits, that is, I try to do the “django path” from the very beginning.
I have a view that receives binary data as a post http field. Now, Django, of course, will auto-convert my binary data to a unicode string.
My question is: how can I get raw binary data?
A few things happened to me. Let requestis the request that I am processing.
- Usage
request.raw_post_datawill include parsing the data again - when it actually request.POSTactually stores the raw data, and I'm actually just trying to get around the conversion on the fly (and also, this is new in the development version). - Using base64 or so to transfer data will work, but the overhead seems too big when data transfer itself is not a problem.
- Executing
request.encoding="foo"before getting this field (and reassigning subsequently) does not work either because I still get the Unicode string, but I feel a bit dirty hacking. Using "base64"here (not as bad as for transfer coding) gives me
AssertionError.
Thanks for your ideas!
EDIT:
- , , POST. , , , - script. POST , .