Django REST framework


Posted:

Has multiple parser for incoming data. By default can accept the traditional x-www-form-urlencoded and json formatted data. We should use request.DATA since this contain data coming from PUT, POST and PATCH method. request.POST will only contain POSTed data. The following request should be equivalent:-

curl -H 'Content-Type: application/x-www-form-urlencoded' -d 'name=kamal&addres=jb' -X PUT http://localhost:8000/api/talents/12345678/

request.DATA:-

<QueryDict: {u'name': [u'kamal'], u'addres': [u'jb']}>

curl -H 'Content-Type: application/json' -d '{"name": "kamal", "address": "jb"}' -X PUT http://localhost:8000/api/talents/12345678/

request.DATA:-

{u'name': u'kamal', u'address': u'jb'}

List of supported parsers is stored in request.parsers

request.parsers
[<rest_framework.parsers.JSONParser object at 0x3020210>, <rest_framework.parsers.FormParser object at 0x3020110>, <rest_framework.parsers.MultiPartParser object at 0x3020250>]
Comments powered by Disqus

About me

Web developer in Malaysia. Currently work at MARIMORE Inc building internet services using Python and Django web framework.

ImportError is an error message emitted by Python when it failed to load certain module as requested by programmer. It's a very common error when someone new to the language trying it out. This website on the same theme, will try provide help for newcomers on any technologies to overcome their first hurdle.

Try most of the examples you may find here on Digital Ocean cloud service. They provide excellent VPS at a very cheaper price. Using this referral link you'll get USD10 credits upon sign up. That's enough to run single VPS with 1GB RAM for a month.

Others

I can also be found at the following sites:-

  • http://k4ml.blogspot.com/
  • http://k4ml.github.io/
  • http://metak4ml.blogspot.com/
  • http://www.mydev.my/
  • http://github.com/k4ml/

Disclaimers

The postings on this site are my own and don't necessarily represent my employer's positions, strategies or opinions.

Share