Skip to content

Instantly share code, notes, and snippets.

@glassresistor
Created June 25, 2013 21:09
Show Gist options
  • Save glassresistor/5862435 to your computer and use it in GitHub Desktop.
Save glassresistor/5862435 to your computer and use it in GitHub Desktop.
MultipartResource tastypie
class MultipartResource(object):
def deserialize(self, request, data, format=None):
if not format:
format = request.META.get('CONTENT_TYPE', 'application/json')
if format == 'application/x-www-form-urlencoded':
return request.POST
if format.startswith('multipart'):
data = request.POST.copy()
data.update(request.FILES)
return data
return super(MultipartResource, self).deserialize(request, data, format)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment