Django RESTful API - django-piston vs. django-tastypie

后端 未结 4 1173
梦毁少年i
梦毁少年i 2021-01-30 04:45

We\'re looking for a general RESTful API solution for our Django project. We would use the API at first for Ajax calls on the web site and later for mobile apps, external apps a

相关标签:
4条回答
  • 2021-01-30 04:52

    Django REST framework 2.0 was anounced in Oct 2012 and now supports OAuth out of the box. What I really like is the Web browseable API, which is really helpful when developing your API, but also when someone implements your API. It's kind of comparable with using the Django admin site for inspecting your models' structure and data, but then for your API. Also the documentation is very good.

    From their website:

    Django REST framework is a powerful and flexible toolkit that makes it easy to build Web APIs.

    Some reasons you might want to use REST framework:

    • The Web browseable API is a huge usability win for your developers.
    • Authentication policies including OAuth1a and OAuth2 out of the box.
    • Serialization that supports both ORM and non-ORM data sources.
    • Customizable all the way down - just use regular function-based views if you don't need the more powerful features.
    • Extensive documentation, and great community support.

    Check out their Quickstart guide to get a quick idea of how it works.

    0 讨论(0)
  • 2021-01-30 04:58

    I have no experience with this, but I trust Pydanny in this:

    django-piston has been barely supported for nearly two years. That is an eternity, and the number of forks to address multiple issues is a cause for alarm. Because of that, in it's place at this time I recommend django-tastypie. It is up-to-date, has very good documentation, supports OAUTH, and scored second place in the Django Packages thunderdome (it got nearly 3x as many points!). Another tool to consider is Django Rest Framework, which is as good as django-tastypie but lacks the OAUTH support.

    On the django-piston front, Joshua Ginsberg has taken over the reins and we should hopefully see some movement again. In which case I'll be able to remove this section of the blog post.

    from Pydanny's blog.

    0 讨论(0)
  • 2021-01-30 05:01

    Having implemented API's with django Piston, tastypie and django webmachine Django tastypie rocks! Having said that, I think that while tastypie is really good when your API is modelled close to your models, it's a little bit more complicated to do things once you want to move out of the box. There are workarounds to some issues, with others you have to do more bending than building. It will, probably, still cover 90% of django use cases.

    Afaik Webmachine was modelled after the popular erlang webmachine, but hasn't been very active lately. So that leaves piston, which is picking up some activity, and tastypie, that has a lot of momentum and activity. Piston is a bit more flexible, but tastypie is moving very fast and in my opinion has a really easy API.

    My recommendation would be to quicky implement a prototype of the API in tastypie, and see if it covers what you want to do.

    0 讨论(0)
  • 2021-01-30 05:06

    A good resource to compare them is http://www.djangopackages.com/grids/g/api/

    Django-tastypie sure is the save choice right now.

    Personally I'd advocate a look at django-rest-framework if you use django 1.3, because it uses the new class based views. djangopackages.com's comparison page shows it has good participation and activity. And, wow, it sure has a nice browsable interface to the API.

    0 讨论(0)
提交回复
热议问题