Hacker News new | past | comments | ask | show | jobs | submit login
Zed's "One Battery Review" of Django (zedshaw.com)
188 points by jacoblyles on March 20, 2009 | hide | past | favorite | 35 comments



As a huge fan of Django, Python, and both communities I would like to point out a few more things:

- Always track the trunk, there's really no compelling reason not to. It's always extremely stable and full of new features you won't find in the tarball release.

- The ORM is good for simple things, but you may find yourself needing to write SQL if you're doing anything complicated. In reality this probably applies to any ORM, though. Even though people ignore it.

- Caching is built-in, effortless, and awesome.

- The template language is intentionally crippled in various ways to keep you from "doing too much" in them. Thankfully Django is modular enough to allow you to drop in a more powerful replacement if that's your thing.

- Django is basically retarded when it comes to multi-processing environments and should not be considered even remotely thread-safe. I mean it. Copious use of locks can usually keep transactions from walking all over each other, but your mileage may vary.

- If you want some piece of functionality or add-on or whatever, chances are somebody has already written it. Check djangoplugables.com and djangosnippets.org before wasting precious cycles.


Good point about ORM for any framework. Eventually you'll have to write SQL, so why use the ORM in the first place?


I didn't find Zed's review much of a review at all. He doesn't go into a lot of what's going on under the hood which would really take more than one battery but is typically more Zed's style.

What Zed does talk about are the conceptual things that make Django appear good on paper like reusable applications and he also likes Django's tip of the hat to Jazz. It's too bad he doesn't talk about stuff like the crazy ORM that Django has which seems to be the least Pythonic ORM out there, or whether or not Django handles string encodings well, caching, etc. That's the kind of detail I've enjoyed from Zed's previous reviews... err... rants. Hopefully we'll see some more substantial review in the future.


He actually makes it quite clear that this is a superficial overview.


Damn. The day after I claim he's been doing nothing for the past year, he goes and posts a fairly interesting review of django.

Now, lets quote Zed:

"Read it, and take it as a chance to discuss pseudo-macho speech online, and whether you really are only listening to perceived strength rather than reason."

I did some searching, and the highest ranked similar post I could find is this one which currently has 31 points:

http://news.ycombinator.com/item?id=404309

Want to bet this article gets more points? :)


39 points within an hour or so. I'm not really sure what to take from this tbh.


I really like the idea of measuring writing in laptop batteries. Start writing, unplug the laptop, when it's about to die, wrap things up.


My laptop battery only lasts about 25 seconds. Microblogging it is!


emacs is actually awesome for Python programming. For easy Python coding, just add the following to your .emacs file:

  (setq-default tab-width 4)
  (setq-default indent-tabs-mode nil)
Also get ipython.el -- very handy. My .emacs is here for your reference: http://github.com/ki/my-dot-emacs/blob/master/dot-emacs.txt


This was the tutorial shed a lot of light on the issue: http://student.northpark.edu/pemente/emacs_tabs.htm

You get to configure at least three things: how many things emacs enters when you press "tab", what those things are, and if you see a tab in a file how wide it should be.


Anybody have a good .vimrc file for Python, or thoughts on customizing vim for Python?


Use the indentation script pointed to and explained by this article: http://henry.precheur.org/2008/4/18/Indenting_Python_with_VI...

It is better than the default vim python autoindentation behavior.


Actually, I think vim comes with pretty good Python support by default. I'm using vim 7.1 and there's, for example, a good python.vim syntax file that came with.



No. 1 thing about Django that annoys me(1) is that the Admin-interface, in all it's awesomeness isn't modular and pluggable. I want to put CRUD+filtering lists on the non-admin part of the site, and can't seems to find a non-hacky way of doing it.

(1) The list thins out a lot after than. I agree with Zed that the apps-in-a-site structure is very cool.


Do you know about generic views? http://docs.djangoproject.com/en/dev/ref/generic-views/

...and ModelForms? http://docs.djangoproject.com/en/dev/topics/forms/modelforms...

In my experience, "simple CRUD" often gets complicated by permissions or other special cases, but generic views and modelforms are useful tools for hammering out a lot of the basics very very fast. Both of them allow for some degree of customization, but should be helpful in achieving what you want.


The admin annoys me for same reason. It's too awesome to throw away, but wasn't quite malleable enough. This is changing for the very much better in next release/trunk.


very good overview. i have been learning and utilizing django in most recent project and generally liking it as well. the things i like the most are the orm, and the modular application architecture is truly potent. missing however - and some would have the opposite feeling - the greater opinionation of rails ... i for one welcome a crystallized project structure. my rails projects still read so elegant, clean, and paired down comparatively.


That was pretty much my first impression of Django as well, and I bet it's the impression they want to leave.

The reality doesn't really hit home for a few weeks. Django gives you all sorts of really cool stuff right out of the box that does nearly everything for you. The problem comes when you want to do something just that little bit different, and you find yourself unrolling every single piece of it one-by-one as you discover that these pieces don't fit your needs exactly.

I also found myself baffled by the terrible decision to make everything revolve around function calls rather than a Request and Response object. No matter what happens in your page flow, you still need to return a HttpRequest object at the end of the day. No more Response.Write();Response.End(); from any point. You need to have every bit of code capable of returning in a way that triggers the thing above it to return in a way to trigger the thing above it to return a HttpRequest object. Makes debugging a serious pain.

So yeah, if you're doing a simple CMS for a media site (which is what they wrote Django to do), it rocks the house. If you're trying to do any heavy lifting, it seems to fall apart pretty fast.

I don't think I'd use it again.


> No matter what happens in your page flow, you still need to return a HttpRequest object at the end of the day.

I think you mean HttpResponse object. We must use Django differently (Do you use templates and contexts?) I don't understand what you are saying in your bafflement paragraph. And your evaluation of good for simple but not for heavy lifting is the exact opposite of mine. I love Django cause it makes the simple, simple and and the hard, possible.

Each view function takes a Request + parameters and returns a Response. Simple, consistent, and flexible. Easy to write decorators. Easy to reuse view functions, easy to compose view functions from parts. Easy to ditch the whole thing and roll your own.

Django is extremely well decoupled. It comes with all sorts of batteries included but it's very easy to take out a battery and use your own. Templates, storage, url routing are all easily replaced. Apps can come and go, middleware can come and go. And most the functionality admin/auth/caching/templates/storage backend/sessions/etc are split out into apps and/or middleware so it's easy to replace/extend if you need to do something special. Recent releases have made even made the admin much easier to customize without wholesale replacement.

I've even used Django for non web apps. I didn't have to do anything particularly special. It just worked.

P.S. If you think "media"/newspaper sites are simple, you don't know newspaper sites.


Interesting, I spent most of the last year working on two serious Django apps, both of which were very different from the kind of sites Django was first designed for. Replacing the things that didn't work for us with custom components was incredibly easy. By writing middleware and custom template tags we were able to quickly add the functionality we needed.

Sure, there were times when we were frustrated by some Django design decision, but ultimately I walked away really happy with Django as a framework. In the past I have used Rails and Pylons and so far I prefer Django and will likely use it as a starting point for most of my web development, at least until I can start using Clojure more often.


I've been hacking Django apps around 50kLOC for a couple of years and have found it generally very well designed. It is true that the best-documented interfaces often don't meet your needs exactly, but I've had a lot of good results reaching into Django a bit. Sometimes this just means using some inconspicuous base classes instead of more "convenient" subclasses. Other times it results in some hacking monkey patches. But on the whole, I've found that it saves me time frequently, and in cases when it won't, it gets out of the way pretty fast.

That said, it is still a full-stack framework, and it is definitely targeted at sites that mostly serve dynamic pages. Like all frameworks, it has its archetypal projects, and for Django it's blogs/CMS/online community apps. The further your project is from that archetype, the less useful the framework will be.


I've always found django pretty hackable. If you really want to break the flow of returning objects, you can always use threadlocal to store the request object, the template, or whatever else you want.


I've not used Django but I'm intrigued by your thoughts. I want to stick with Python, do you've a recommendation for a Python web-framework?


I've had a very similar experience, but I have been wanting to see how the more current versions hold up.


Thanks for your comment. Zed's review got me pretty interested in Django, but since I'm not building any CMS's for media sites, I'll just stick with Rails and merb for now. Thanks for saving me some time :)


> At this point, the only warning I’ve received is that deployment is hard, but then, deployment is hard with every web application once you start getting serious.

I have 5 django sites running at the moment and can't say that there are any deployment issues I came across. And its only getting better now that we gonna probably see "multi-database" support I'm guessing in ver 1.2


Is there a Rails equivalent to "The Admin"?


Not really. There have been several attempts since 2005 to create Super Auto-Scaffolding (streamlined, ActiveScaffold, and several other generic names that I don't remember, like "Ajax Scaffolding"). These aren't identical to Django's admin, but they could serve a similar purpose.

For all of its innovation, I'm a little surprised that the Rails community hasn't put together a quality solution for this problem yet. I assume the ORM differences are a part of this - Django's ORM (I think?) defines the schema in the application, while ActiveRecord gets this from the database directly. But does that really make a Django-style admin impossible with ActiveRecord?


Not that I've seen (maybe in a plugin?) That being said if you use scaffolds to create your models, some of this functionality will be there (CRUD actions on models). You still would need to add a navigation wrapper around these (pretty easy) and the authentication.


We recently switched to Python at work (and personally, I have a few projects at home as well).

We opted to go with the web2py framework at work but I have been giving Django a long, hard look for some of my personal work.


Be sure to take a look at Werkzeug ( http://werkzeug.pocoo.org/ ) - we've had great success with a Werkzeug, jinja2 and SQLAlchemy setup.


Zed writes:

> Now, I know that when I drop the f-bombs and do crazy shit like disagree with people they get their panties in a bunch and call it trolling

Actually, no, folks DON'T tend to take simple disagreement as trolling.

However, it's crucial to Zed's self image as an "outlaw rock-and-roll biker" that his opinions not be accepted, and that he be a renegade, so he has to remind us each and every time he posts "hey, look at me - I've got an opinion. Isn't that just so DARING of me?"

Yawn.


You actually missed the point entirely, where Zed's saying that he doesn't want to piss people off but that he still thinks "fucking" is a necessary descriptor to announce his emotions.


I'm not sure if Zed impregnated a member of your family, or pissed in your coffee or what, but maybe you should wait to comment until you have something of substance to say.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: