[TriZPUG] Wanted: Biased Opinions: Django or Pyramid (Pylons/BFG)?

Johnson, Josh jj at email.unc.edu
Mon Apr 4 20:18:36 CEST 2011

Thanks for the responses, everyone. 

First off, I forgot to mention my username on IRC is jjmojojjmojo :) So if anyone was looking to strike up a conversation there, that's me.

Here are my thoughts on the subject:

I think that Django has a lot to offer in a lot of key areas where Pyramid may be lacking. The ones that have stood out to me so far include: available add-on products (especially user registration/management), overall maturity, the automatic administration interface, and the tight ORM integration (notably South, used for schema migrations). 

They both have a great developer community, great documentation, a decent model for getting URLs to invoke code[1], acceptable testing stories, reasonable levels of extensibility, and getting started is quick and painless in either case.  

I've been mulling over this all weekend, got more comfortable with the 'why' behind Pyramid's approach[2], and I've come to some conclusions:

When I did Django it felt like I had to understand a specific methodology to get things done. It reminded me of Plone; I had to become indoctrinated in the Django Way(TM) before I could really get good at it. Granted, I think that takes a lot less time with Django, and the outcomes might be more satisfying, but the problem is the same. 

It really became apparent when I had to get back to an in-progress SQLAlchemy-based project shortly after doing Django ORM. It felt like I was learning SQLA all over again, and it really impeded my progress.[3] 

With Pyramid, I had trouble at first because the code skeletons and documentation are geared toward someone who wants to get up and running and doesn't care about what it's doing.  They cover a small set of common use cases, without a lot of explanation. The little bit of documentation that touched on the edge cases was not as stellar as the core docs. 

It was frustrating; I had trouble seeing where I had to intercede if I wanted to add something that was missing. Evaluating middleware and external components was made more difficult by the fact that Pyramid is so new, and used to be repoze.bfg. It was due to my own ignorance of how WSGI and PasteDeply/Script work, for the most part, but still an impedance. 

That said, after coming to a good understanding of WSGI and what exactly Pyramid was doing for me, I can't see using anything heavier. Heck, I'm tempted to just use WSGI and >maybe< WebOb. :P I'm comfortable writing things at a low level, what are the frameworks even buying me?[4]

People keep telling me that getting up and running fast is always the best way. Pick a framework with the most out-of-the-box features you need, and hack your way to making it work for you. You'll have time to refactor later! 

But in my experience, it seems that that's always a mistake. There's never time to refactor. Then the application breaks, it gets slow, it doesn't do what you need the way you thought. Then you're scrambling and hacking and tracing and posting and chatting your proverbial behind off trying to get it working again. And you don't have time to think, or thoroughly dig into the code. More often than not, you learn nothing, or worse: you learn the limitations of the framework.

What I need is something I can understand, so I can say with confidence what's wrong when things go bad, and fix it. I'm sick of telling my users "Sorry, that's a Plone bug, there's nothing we can do" or hacking around problems because I don't have time to figure out what's really wrong. And I don't have time because it takes too long to really understand what's going on under the hood[5] 

I don't want to put myself in that position with a whole new framework that tries to make web development easy for everyone, but makes life hard if you don't run plays from their book.

So I've decided I'm going to utilize WSGI, and keep the frameworks in play to a minimum. Pyramid will probably be a good place to start, since I think it'll handle a lot of the simple web application issues well (I think it may do too much in some areas, but I may be able to tease out the pieces I need if it gets to be too much). 

I know it's not a perfect approach, but the WSGI middleware story solves a lot of the issues I've had with add-ons in Plone and Django in the past. The middleware is a black box. No API to learn or adapt to, just a specific input and an expected output. If it doesn't work for me, I can swap it out for something else. 

If I need ORM, I'm already pretty good with SQLAlchemy, I can use that.  

Ultimately, I think what I've learned from this is that I'm through being a Web Developer. It's time I embraced the fact that I'm a _Programmer_. I'm not going to let myself or anyone I work with be complacent any longer[7]. If I had never programmed before, or never did web programming before, I could see the benefit of a batteries-included framework like Django[7]. But my development team and I are way past that point. It's time we took responsibility for the code we write, and stop being afraid to get down and really get into it. I'm confident it won't take us any longer, and we'll end up with a better user experience, which is why we do this in the first place, right?

And anyway, Django developers might be a dime a dozen, Plone developers might be hard to find, and Pyramid developers might not exist... but Pythonistas are many! Viva La Pythonista!


[1] I don't have a preference really between the various approaches, I can work with either one.
[2] I dug into WSGI and paster and came to a new appreciation of just how flexible of a 'framework' it is, see: http://lionfacelemonface.wordpress.com/2011/03/30/wsgi-and-paste-deploy-the-bare-necessities/
[3] That's not a criticism of Django's ORM, I think it's really nice; it was just so similar yet so different to SQLA that it seems odd that the two satisfy the same problem domain.
[4] I really do know the answer to this, especially on a fundamental level. Things like GET/POST handling, connection management, URL processing, etc. It's the other stuff that I'm finding suspect.
[5] I think this is really due to the fact that I'm living in the high-level API most of the time. 
[6] I believe very strongly that Django has it's place and is a great framework, but trying to serve so many use cases with so much magic is something you do when you're userbase isn't technically astute.
[7] friends and acquaintances: you're next! ;)
[8] ... or TurboGears, or Ruby on Rails, or Zend Framework, or Drupal... :P
From: trizpug-bounces+josh_johnson=unc.edu at python.org [trizpug-bounces+josh_johnson=unc.edu at python.org] on behalf of Josh Johnson [josh_johnson at unc.edu]
Sent: Tuesday, March 29, 2011 9:16 AM
To: Triangle (North Carolina) Zope and Python Users Group
Subject: [TriZPUG] Wanted: Biased Opinions: Django or Pyramid (Pylons/BFG)?

This isn't a typical "I've never used a web framework, what should I
pick" post, I promise.

I'm about to embark on a new project that doesn't have a platform
requirement. I've spent the last year or so working on a very large,
very anno--er--challenging Plone project, and I'm ready for something

I'm honestly interested in hearing _biased_, non-objective, highly
personal accounts of why I should use Django or Pyramid.

I've got more-than-basic understandings of both, but I don't have a
large amount of real-world experience with either. I'd feel comfortable
proceeding either way.

I know there are a lot of very smart people around here using both to do
some really big things, so I figure, this might be my best chance at
getting some usable advice :)

I also think very highly of our community and don't see this devolving
into a flame-war. However, I'm very OK with discussing this off-list, on
#trizpug, 'IRL', over food, in a sauna, whatever. My passport isn't
current, so clandestine meetings in countries without extradition
treaties are out. :P

I'm very happy to elaborate on the requirements we do have, but it's a
pretty basic app that I think either platform could handle well. It'll
be open source, so easy deployment is important, but I think both
frameworks cover that well.


Josh Johnson
Applications Analyst
Lineberger Comprehensive Cancer Center
University of North Carolina at Chapel Hill
TriZPUG mailing list
TriZPUG at python.org
http://trizpug.org is the Triangle Zope and Python Users Group

More information about the TriZPUG mailing list