This is a transplant from the original Irrational Exuberance, and was written in mid 2007: nearly two years ago. It was my first article to be read outside of my immediate group of friends and was picked up on Reddit programming. It is unquestionably quaint, but I only started proofreading my blog entries in the past six months, so I won’t profess a particularly strong attachment to perfection.
一位朋友最近让我把我的思想一起举起,我对使用Django作为一个发展框架,所以这里是一项试图迫使他,并一般上巩固了我对Django的看法。在过去的两个(也许三个......)周,大部分时间都是每天都处于我的一天的最前沿。当我开始时,我以前从未使用过Django,但此时我已经阅读了它的源极限(这是一个要求的东西,当您想做一些棘手的事情 - 特别是在较新的组件上差点),并认为自己在使用框架时相当能力。所以,没有进一步的ADO,我们走了。
Easy to learn
我要对Django说出最好的事情之一,这是相当容易接收。抛出一些时间,它将恭敬。我以前的项目在此之前(这也可能是我的下一个项目,愚蠢的中断)使用PyoBJC框架在Python中为OS X编写Cocoa应用程序。对于他们的框架来说,Getitng对前3-4天的框架非常令人沮丧。它有一个高学习的曲线(特别是缺乏任何人,我很容易转向并要求他们指出我是一个完整的废弃物的地方),而Django根本没有这样的痛苦学习曲线。如果您通过他们的教程工作,您将获得一个
fantastic充分理解如何使用他们的框架,and reading their online documentation can get you 97.2% of the way to a finished product. Its only when you do relatively tricky stuff (or use a new module) that you'll have to dive into source code.So, really easy to learn, thumbs up to Django.
足够强大
Anything I wanted to do in developing my webapp, Django was
more or less准备促进我。有时候,我完全介入我想要涉及很多代码。我的views.py(django使用修改后的MVC范例,但观点内容或多或少的视图对应于THE的MVC概念)在一点上几乎是1000行。自从将表单分开到一个单独的文件(表单基本上是在视觉上代表模型的方式,所以我包含进入观点.py文件只是适度糟糕的),并计划将观点分开。分开崩溃了(实际上,我昨晚分开了它,内容创建系统肯定是大部分的观点,进入大约500-600行,往往允许您跳过这段代码,但不在我的情况下),但仍然是对您的数据进行高粒度控制,您最终撰写了很多观点。值得指出他们确实有一个通用模板系统,但它并没有真正拥有我需要的灵活性和功率我的项目。我想到了许多简单的项目,强调显示数据而不是创建它是琐碎的易于在Django(django管理员稍后的更多想法)中。值得指出观点的观点不是难写的代码,但有时候我宁愿通过一堆填充来编写困难的代码(pyfilling?是项目名称已经是一个项目名称)。所以,这对Django来说,这是有利的虽然有点会加剧,但它可以做到你需要的东西,或者至少它很容易学习新技巧。
Django Admin
Django管理员真的很令人乐意地与你一起工作 - 当你第一次开始时。它始终惊人地获得如此多的功能“免费”。这是一个很棒的工具。也就是说,它不是很灵活,如果你想对它进行重大修改,建议本质上是滚动自己的。布拉。有一个在一个更灵活的Django管理工具(即粒度权限)上工作的分支项目,但我希望它会很长一段时间。即使他们完成它,也不清楚他们正在使用newforms(Django正在从他们的旧的形式切换到一个新的形式,但目前他们的许多模块仍然使用oldforms)(有一个Newforms管理分支项目也是如此,所以它可能很长一段时间.My判决管理员是它的奇妙如果你想用它可以用它可以做的事情,并且是尝试延伸的完全灾难有意义的方式(我试过了一段时间,虽然我仍然学习Django绳索,但这是一个大屠杀,每个人都输了)。
中间件,特别是身份验证和会话
The Authentication/Sessions middleware are fantastic. They let me implement a login/logout/registration system really quickly and easily. There are generic views for these activities, although I chose not to use them (they use oldforms, and I was sticking entirely with newforms, and the benefit from mixing seemed too low to justify the confusion). Really easy to use, and fantastically helpful.I should also mention that the Caching middleware is also fantastic. I setup caching for my website in approximately ten minutes, after reading the documentation for maybe 20-30 minutes to figure out exactly what I wanted to do (although, I am slightly apprehensive that it may be caching more than I want it to, I may have to use the granular caching system that caches only specific pages you specify).Simply put, the middleware are incredibly helpful tools that I can't recommend enough.
伟大的社区
Django has a fantastic and lively community. #django is always lively, and is usually pretty helpful (although, getting redirected to the same bad example on djangosnippets.com can be moderately vexing at times ;P). There are a bunch of fairly helpful guides, mailing lists, and other resources available for Django, so this is a plus for Django too.
调试django没关系
Django调试/错误消息相当有用。偶尔我会对错误屏幕生气,但由于它们提供整个Python回溯,您通常可以弄清楚问题。比矮子的东西更容易调试(不要竖起竖琴,我喜欢这个项目,有时只是痛苦)。
Differences between Devel server and Apache
我有一个狡猾的错误当我转移应用摇来摇去m the Django development server to my production environment (an Apache server). For whatever reason the newforms stopped correctly validating data. Well, they *sort of* validated the data correctly, but they stopped populating the clean_data field within the form. I have no idea why this happened, and I am guessing its because the newforms are relatively new and still under development, but it was fairly frustrating to have to hack a worse solution to a problem I had already solved (on the devel server).
Beta Software
Many of the inconveniences surrounding Django stem from the fact that it is indeed Beta software. This includes my complaints about newforms, the admin being inflexible, etc. I suppose it shouldn't surprise me that much, but sometimes I'd just like it to be a bit more polished.
Summary
In the end, I really like using Django. Its flexible, powerful, and fun to use. It has definite rough spots around the edges, but I'd recommend charging towards them--thats how you'll get to really understand the nature of the beast (or at least improve your code-reading). I am considering using it again in another project, but I may be inclined to use it more for data presentation projects instead of complex web apps in the future. I hear TurboGears is an excellent framework for web applications, so I may try that out eventually. What I'd *really* like to try out is the Lift platform, which is written in Scala, and appears to scale far better than any other comparable product (except maybe something like CakePHP, but I don't know if I can ever consider a php product to be comparable to a framework in python/ruby/scala).Anyway, hope my ramblings were moderately informative, and I'd love to hear any feedback.