Hey, Xavier! Thanks for the tips. It is very helpful! 2017年4月17日月曜日 21時04分35秒 UTC+9 Xavier Ordoquy: > > Hi, > > I’m not sure about the requirements around your use case but options are: > - rewrite the mixins.py classes to add your extra data (let’s say it’s > only JSON that requires it) > - write your own JSONRenderer to add the extra informations and leave > other renderers as they currently are. > > Hopes this helps, > Xavier Ordoquy, > Linovia. > > Le 17 avr. 2017 à 09:52, Yanze Dai <[email protected] <javascript:>> a > écrit : > > I found that the DRF's return value could be various upon different > occasions. So I want to make sure all my JSON return have "code" "message" > or other values nested inside in order to keep consistency of my APIs. > For example: > Success > > {"code": 1, "status": "success", "message": "", > "data": [{"id": 1, "name": "John Doe", "email": "[email protected] > <javascript:>"}]} > Error > > {"code": -1, "status": "error", "message":"Something went wrong","data": > [] } > > The return will always have "code" "status" "message" "data" inside > whatever the result would become. > > After looked up in Google but couldn't find any work-around over DRF. So I > suppose everybody is redefining the APIViews or Mixins (get put post etc. ) > to control the response. But I am not very sure if the return should be > that widely different without a certain pattern. Or is it cool that DRF's > JSON response could be directly adopted as a production case? > > Hope to have some advice from you guys. > Thanks. > > -- > You received this message because you are subscribed to the Google Groups > "Django REST framework" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] <javascript:>. > For more options, visit https://groups.google.com/d/optout. > > >
-- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
