Django RESTful API - django-piston 与 django-tastypie

发布于 2024-12-20 07:58:43 字数 1026 浏览 1 评论 0原文

我们正在为 Django 项目寻找通用的 RESTful API 解决方案。我们首先将 API 用于网站上的 Ajax 调用,然后用于移动应用程序、外部应用程序等。

我发现两个模块似乎被广泛使用。 django-pistondjango-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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

︶葆Ⅱㄣ 2024-12-27 07:58:43

比较它们的一个很好的资源是 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.

小姐丶请自重 2024-12-27 07:58:43

我没有这方面的经验,但我相信 Pydanny :

django-piston 已经勉强支持了近两年了。那是
一个永恒,解决多个问题的分叉数量是一个
引起警报的原因。正因为如此,此时我才处于这个位置
推荐 django-tastypie。这是最新的,非常好
文档,支持OAUTH,在Django中获得第二名
套餐 Thunderdome(它获得的积分几乎是原来的 3 倍!)。另一个工具
要考虑的是 Django Rest Framework,它和
django-tastypie 但缺乏 OAUTH 支持。

在 django-piston 方面,约书亚·金斯伯格 (Joshua Ginsberg) 接手了大权
我们希望能再次看到一些进展。在这种情况下我会
能够删除博客文章的这一部分。

来自 Pydanny 的博客

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.

许一世地老天荒 2024-12-27 07:58:43

使用 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.

叫嚣ゝ 2024-12-27 07:58:43

Django REST 框架 2.0 是 2012 年 10 月发布,现在支持 OAuth 开箱即用。我真正喜欢的是 Web 可浏览 API,它在开发 API 时非常有用,而且在有人实现时也非常有用你的API。这类似于使用 Django 管理站点检查模型的结构和数据,然后检查 API。文档也非常好。

从他们的网站:

Django REST 框架是一个强大而灵活的工具包,使其成为
易于构建 Web API。

您可能想要使用 REST 框架的一些原因:

  • Web 可浏览 API 为您的开发人员带来了巨大的可用性优势。
  • 身份验证策略,包括开箱即用的 OAuth1a 和 OAuth2。
  • 支持 ORM 和非 ORM 数据源的序列化。
  • 可完全自定义 - 如果您不需要更强大的功能,只需使用常规的基于函数的视图即可。
  • 丰富的文档和强大的社区支持。

查看他们的快速入门指南,快速了解其工作原理。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文