django-tastypie和djangorestframework之间有什么区别? [英] What are the differences between django-tastypie and djangorestframework?

查看:150
本文介绍了django-tastypie和djangorestframework之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



http://pypi.python.org/pypi/djangorestframework/



http://pypi.python.org/pypi/django-tastypie

解决方案

作为django-rest-framework的作者,我有一个明显的偏见),但是我对此的希望相当客观的意见就是这样: / p>

TastyPie




  • 正如Torsten所说,你不会走得太远用同样的窥视写的东西与令人敬畏的 django-haystack 一样。从我在邮件列表中看到的Daniel Lindsey等人是非常有用的,Tastypie是稳定,全面和有据可查的文件。

  • Excel给你一个明智的默认行为,使用这种风格构建一个非常容易的API。



Django REST框架




  • 给你HTML浏览自我描述的API。 (EG,请参阅教程API )。能够直接在浏览器中导航和与API进行交互是一种大的可用性胜利。

  • 试图保持Django的成语 - 建立在Django的基于类的视图之上等等(而在Django的CBV存在之前,TastyPie已经出现,因此使用它自己的基于类的视图实现)

  • 我想认为底层架构很漂亮,解耦等...



无论如何,两者都不错。我可能会将Tastypie描述为给您一个明智的默认设置,REST框架非常好地解耦和灵活。如果您计划在API上投入大量时间,我建议您浏览文档和每个人的代码库,并试图获得更适合您的感觉。



显然,还有一个'Why TastyPie?'部分在自述文件中,REST框架2公告



另请参见Daniel Greenfeld的博客文章从2012年5月起为Django选择一个API框架(值得注意的是,这仍然是几个几个月之前的大型REST框架2.0发布)。



还有一些Reddit上的线程与人们问这个相同的问题,从 2013年12月 2013年7月



最后更新时间2014年2月


Why would you use one over the other, for exposing an API for your Django app?

http://pypi.python.org/pypi/djangorestframework/

http://pypi.python.org/pypi/django-tastypie

解决方案

As the author of django-rest-framework, I've got an obvious bias ;) but my hopefully-fairly-objective opinion on this is something like:

TastyPie

  • As Torsten noted, you're not going to go far wrong with something written by the same peeps as the awesome django-haystack. From what I've seen on their mailing list Daniel Lindsey et al are super-helpful, and Tastypie is stable, comprehensive and well documented
  • Excels in giving you a sensible set of default behaviour and making building an API with that style incredibly easy.

Django REST framework

  • Gives you HTML browse-able self-describing APIs. (EG, see the tutorial API.) Being able to navigate and interact with the API directly in the browser is a big usability win.
  • Tries to stay close to Django idioms throughout - built on top of Django's class based views, etc... (Whereas TastyPie came along before Django's CBVs existed, so uses it's own class-based views implementation)
  • I'd like to think that the underlying architecture is pretty nicely built, decoupled etc...

In any case, both are good. I would probably characterise Tastypie as giving you a sensible set of defaults out of the box, and REST framework as being very nicely decoupled and flexible. If you're planning on investing a lot of time in the API, I'd def recommend browsing through the docs & codebase of each and trying to get a feel for which suits you more.

Obviously, there's also the 'Why TastyPie?' section in it's README, and the 'REST framework 2 announcement'.

See also Daniel Greenfeld's blog post on Choosing an API framework for Django, from May 2012 (Worth noting that this was still a few months before the big REST framework 2.0 release).

Also a couple of threads on Reddit with folks asking this same question, from Dec 2013 and July 2013.

Last updated Feb 2014

这篇关于django-tastypie和djangorestframework之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆