Hi.
The Django Rest Framework encourages the use of put for uploading files.
However, django.test.client.Client does not encode multipart data before
simulating the server call. Does anyone know why this has been left out?
The code in django.test.client for *put()* is:
def put(self, path, data='', content_type='application/octet-stream',
secure=False, **extra):
"""Construct a PUT request."""
data = self._encode_json(data, content_type)
return self.generic('PUT', path, data, content_type, secure=secure, **extra)
The code in for *post()* is:
def post(self, path, data=None, content_type=MULTIPART_CONTENT, secure=False,
**extra):
"""Construct a POST request."""
data = self._encode_json({} if data is None else data, content_type)
post_data = self._encode_data(data, content_type)
return self.generic('POST', path, post_data, content_type, secure=secure,
**extra)
As you can see the *put* method doesn't call *_encode_data*. So if the data
happens to include a file and I'm trying to test a file upload, it doesn't
work.
The last issue that I found related to this question appeared in the Django
issues archive in 2009-10.
Thanks!
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/9cc629ff-16d1-4bda-bae4-b16a4123cb32%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.