django - Form POST using TastyPie not json -


i'm getting following error message (see below) when trying post *form data* using tastypie:

no json object decoded

i understand need pass json object in body work, if have form posts , don't want use json (only output in json)

how make tasty pie work form post?

thanks

class smsresource(modelresource):      class meta(commonmeta):         queryset = batch.objects.all()         resource_name = 'sms'         list_allowed_methods = ['get', 'post']         detail_allowed_methods = ['get'] 

make sure content type x-www-form-urlencoded make post , try:

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)      def put_detail(self, request, **kwargs):         if request.meta.get('content_type').startswith('multipart') , \                 not hasattr(request, '_body'):             request._body = ''          return super(multipartresource, self).put_detail(request, **kwargs) 

then in resource class:

class smsresource(multipartresource, modelresource):      class meta(commonmeta):         queryset = batch.objects.all()         resource_name = 'sms'         list_allowed_methods = ['get', 'post']         detail_allowed_methods = ['get'] 

Comments