python Django vs. Pylons
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1344824/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Django vs. Pylons
提问by Kenneth Reitz
I've recently become a little frustrated with Django as a whole. It seems like I can't get full control over anything. I love Python to death, but I want to be able (and free) to do something as simple as adding a css class to an auto-generated form.
我最近对 Django 整体感到有点沮丧。似乎我无法完全控制任何事情。我爱死 Python,但我希望能够(并且免费)做一些像将 css 类添加到自动生成的表单一样简单的事情。
One MVC framework that I have really been enjoying working with is Grails (groovy). It has a FANTASTIC templating system and it lets you really have full control as you'd like.
我非常喜欢使用的一个 MVC 框架是 Grails(groovy)。它有一个 FANTASTIC 模板系统,它让您真正拥有完全的控制权。
However, I am beyond obsessed with Python. So I'd like to find something decent and powerful written in it for my web application development.
但是,我对 Python 并不着迷。所以我想为我的 Web 应用程序开发找到一些用它编写的体面和强大的东西。
Any suggestions?
有什么建议?
Pylons maybe?
也许是塔?
回答by Jason S
I'm using Pylons right now. The flexibility is great. It's all about best-of-breed rather than The Django Way. It's more oriented toward custom application development, as opposed to content-based web sites. You can certainly do content sites in it; it's just not specifically designed for them.
我现在正在使用 Pylons。灵活性很棒。这完全是关于同类最佳的,而不是 Django 方式。它更倾向于定制应用程序开发,而不是基于内容的网站。你当然可以在里面做内容站点;它只是不是专门为他们设计的。
On the other hand, you do end up needing to read a lot of different documentation, in different places, of different quality, to grok all the components. Whereas one of the nice things about Django is that for all the core components, you just read "the" documentation.
另一方面,您最终确实需要阅读大量不同位置、不同质量的不同文档,以了解所有组件。而关于 Django 的好处之一是对于所有核心组件,您只需阅读“the”文档。
The Mako (templates) + SQLAlchemy (DB & ORM) combo is really nice, though. Back when I used Django, I replaced its templating and DB system with them (giving up some of its integration features in the process) and they are standard with Pylons. Mako lets you use Python expressions, which is nice because even though you should separate business logic from design, dynamic sites do require significant display logic, and Django's template tags are clumsy to work with. SQLAlchemy lets you work with the same data model anywhere from the raw SQL level to the object-oriented ORM level.
不过,Mako(模板)+ SQLAlchemy(DB 和 ORM)组合非常好。回到我使用 Django 时,我用它们替换了它的模板和数据库系统(在此过程中放弃了它的一些集成功能)并且它们是 Pylons 的标准配置。Mako 允许您使用 Python 表达式,这很好,因为即使您应该将业务逻辑与设计分开,动态站点确实需要重要的显示逻辑,而且 Django 的模板标签使用起来很笨拙。SQLAlchemy 使您可以在从原始 SQL 级别到面向对象的 ORM 级别的任何地方使用相同的数据模型。
I think it's worth the time to at least go through the docsand do the QuickWiki tutorial.
我认为至少花时间阅读文档并学习 QuickWiki 教程是值得的。
回答by Tristan
Pylons is not that much simpler than Django and it doesn't seem to have the same community. For lightweight apps I would recommend web.py. Even though there is a little magic, it doesn't feel like it. You see everything you do. For lots of other ideas see this very current list of web resources on python.
Pylons 并不比 Django 简单得多,而且它似乎没有相同的社区。对于轻量级应用,我会推荐web.py。虽然有一点点魔力,但感觉不到。你会看到你所做的一切。有关许多其他想法,请参阅python 上的最新网络资源列表。
回答by Daniel Naab
回答by Stijn Debrouwere
With the risk of going a bit off-topic here, "I want to be able (and free) to do something as simple as adding a css class to an auto-generated form" might not be the best indicator of the power (or lack of power) of a framework. Form generation is notoriously hard to do in a flexible way (cf. http://blog.ianbicking.org/on-form-libraries.html), and frameworks will always need to weigh ease-of-use versus supporting advanced use-cases. I've used form generation in Pylons before, and didn't find it to be particularly better or easier than how things work in Django (but not harder either).
由于这里有点偏离主题的风险,“我希望能够(并且免费)做一些像将 css 类添加到自动生成的表单一样简单的事情”可能不是功能的最佳指标(或缺乏力量)的框架。众所周知,表单生成很难以灵活的方式进行(参见http://blog.ianbicking.org/on-form-libraries.html),并且框架总是需要权衡易用性与支持高级使用 -案件。我之前在 Pylons 中使用过表单生成,并没有发现它比 Django 中的工作方式更好或更容易(但也不难)。