Django vs Tornado

There are at least two major reasons:

Batteries included with Django: ORM, sessions, authentication, admin, etc.

Tremendous ecosystem of apps (addons) and tools that Django community has built over the years

Tornado's own web site refers to it as a "web server and networking library" rather than a "framework". It feels nice on small projects where none of the above is necessary and if you need to serve many long-standing connections you don't have much choice, but in all other cases Django will come way far ahead in terms of productivity.

知乎使用的是Tornado框架。因?yàn)樗С之惒?,很適合做實(shí)時(shí)Comet應(yīng)用,而且簡單輕量,學(xué)習(xí)成本低,再就是有FriendFeed的成熟案例,F(xiàn)acebook的社區(qū)支持。知乎的產(chǎn)品有個(gè)特性,就是希望跟瀏覽器端建立一個(gè)長連接,便于實(shí)時(shí)推送Feed和通知,所以Tornado比較合適。

----------------

To me, a big Tornado fan, a MAJOR plus for Django is it's ORM. If you have a SQL database, use Django.

-----------

Tornado is a web server?and?a web framework by most definitions, but it's quite a minimal framework (compared to Rails or Django). Tornado modules are loosely coupled, so it's possible to use just the web server component (or even just the lower level IO loop). Compared to Django, there are a lot of areas where Tornado doesn't have as much functionality. For example, there isn't really a model abstraction in Tornado, you have to roll your own.

When you run a Tornado app behind Nginx, that's your app running – Nginx just proxies to it. I believe Tomcat is an application server, distinct from your application. I wouldn't call Tomcat a web framework.

Django is not asynchronous, so generally your app will block while using the Django components. This may not be a big deal, it depends what you're doing.The Tornado devs have stated(paraphrasing heavily) that for most applications, the biggest win comes from not blocking while waiting for the client, i.e. web browser. Blocking on the database, for example, is not a big deal if you keep your queries fast.

There are a lot of pros and cons for both Django and Tornado, and there are many alternatives to both - it's definitely not just a choice between the two. Here's averyquick list of why you might want to use Django though:

Pros for Django:

it's a fuller stack (admin pages for example are very easy to implement)

it's much more established (plugins, tutorials, etc.)

it's better documented

its ORM is very nice

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容