Django RESTful API - django-piston 与 django-tastypie
我们正在为 Django 项目寻找通用的 RESTful API 解决方案。我们首先将 API 用于网站上的 Ajax 调用,然后用于移动应用程序、外部应用程序等。
我发现两个模块似乎被广泛使用。 django-piston 和 django-tastypie
从我读到的来看,活塞似乎更老,因此更成熟,但也许有点过时了?! 虽然 tastypie 相对较新并且有很好的文档记录。
最好搭配什么? django-piston 还是 django-tastypie? 对我们来说很重要(按优先级排序):源代码、文档、稳定性、易用性的持续维护。
编辑(2013 年 7 月 16 日):
一年多后的现在,我们有了明显的赢家。起初我们选择了美味馅饼。我们有点喜欢。但大约半年后,我们转向了当时即将推出的 django-rest-framework再也没有回头。
我们最喜欢它的地方:
漂亮的文档
活跃的社区
干净的设计(基于 django 的基于类的视图构建)
用于开发和调试的可浏览 API
我们严重依赖 API,因此支持(将来)是我们主要关注的问题之一。我们遇到了维护者 - Tom Christie -(线上和线下),他似乎非常致力于该项目。所以我们使用 django-rest-framework 感觉非常舒服。
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 and things like that.
I found two modules which seem to be widely used. django-piston and django-tastypie
From what I read, piston seems to be older and thus more mature but maybe a bit outdated?!
While tastypie is relatively new and nicely documented.
What would be the best thing to go with? django-piston or django-tastypie?
Important for us (ordered by priority): Continuous maintenance of the source, documentation, stability, ease of use.
EDIT (2013 Jul 16th):
Now over a year later we have a clear winner. At first we went with tastypie. Which we kinda liked. But after half a year or so we switched to the then upcoming django-rest-framework and never looked back.
What we like most about it:
Nice documentation
Active community
Clean design (build upon django's class based views)
Browsable API for development and debugging
We rely on the API heavily so support (in the future) is one of our main concerns. We met the maintainer - Tom Christie - (on and offline) and he seems very committed to the project. So we feel very comfortable using the django-rest-framework.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
比较它们的一个很好的资源是 http://www.djangopackages.com/grids/g/api/
Django-tastypie 肯定是现在的保存选择。
就我个人而言,如果您使用 django 1.3,我建议查看 django-rest-framework,因为它使用新的基于类的视图。 djangopackages.com 的比较页面显示其具有良好的参与度和活跃度。而且,哇,它确实有一个 API 漂亮的可浏览界面。
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.
我没有这方面的经验,但我相信 Pydanny :
来自 Pydanny 的博客。
I have no experience with this, but I trust Pydanny in this:
from Pydanny's blog.
使用 django Piston、tastypie 和 django webmachine 实现 API Django tastypie 非常棒!话虽如此,我认为当你的 API 建模接近你的模型时,tastypie 确实很好,但一旦你想要开箱即用,做事情就会有点复杂。有些问题有解决方法,而其他问题则必须执行比建筑更弯曲。它可能仍会覆盖 90% 的 django 用例。
Afaik Webmachine 是根据流行的 erlang webmachine 建模的,但最近不太活跃。因此,剩下的活塞正在发挥一些作用,而美味派则有很大的动力和活动。 Piston 更灵活一些,但 tastypie 的发展速度非常快,而且在我看来,它有一个非常简单的 API。
我的建议是在 tastypie 中快速实现 API 原型,看看它是否涵盖了您想要做的事情。
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.
Django REST 框架 2.0 是 2012 年 10 月发布,现在支持 OAuth 开箱即用。我真正喜欢的是 Web 可浏览 API,它在开发 API 时非常有用,而且在有人实现时也非常有用你的API。这类似于使用 Django 管理站点检查模型的结构和数据,然后检查 API。文档也非常好。
从他们的网站:
查看他们的快速入门指南,快速了解其工作原理。
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:
Check out their Quickstart guide to get a quick idea of how it works.