What's better to use for Django? [closed]
Django-rest or Django Pistons?
What's better plugin for API stuff?
I've not used django-rest, but I have used django-piston and found it really effective and pretty easy to get up and running quickly.
It also seems to be a popular choice with a lot of devs I know - and it powers the API for bitbucket, which I take as a good sign.
For me, the primary pinch-points are:
if you're looking to create hybrid representations of your data models (eg you want the standard User resource representation to show all the fields, but (as an example - I don't want to start a REST war here) you also want your Foo representation to show a limited, nested subset of User fields) then you have to write more complicated Resource definition code to do that, because the class-based setup only allows one representation of a given model that automatically gets reused whenever that resource is needed. (Which is actually a good thing, but can be a constraint if you have to bend the output a bit.)
if any of your models store actual XML, you'll have to write a smart/non-escaping emitter to handle it, which is more about punching getting busy with your favourite XML library (tip: ElementTree)
Even with those two things in mind, piston has been my go-to resource for knocking up a quick API, and I've been very happy so far. I am tempted to try django-tastypie next, though
I personally like Piston. It seems like it's got an active mailing list and it is pretty customizable. I like that is pretty flexible as to what type of output formats that you can request from it. Also, creating your own authentication module is pretty easy. I haven't really used django-rest though.
精彩评论