views:

1139

answers:

8

Django is my favorite python web framework. I've tried out others like pylons, web2py, nevow and others.

But I've never looked into TurboGears with much enthusiasm.

Now with TG2 out of beta I may give it a try. I'd like to know what are some of the pros and cons compared to Django.

+13  A: 

TG2 takes Pylons and changes some defaults - object dispatching instead of Routes, and Genshi instead of Mako. They believe there's only one way to do it, so apps can rely on the same API for any TurboGears website.

Similarities

  • TG2 and Django both distinguish between websites and components, so you'll eventually see reusable building blocks for TurboGears, too.

Differences

  • Django uses its own handlers for HTTP, routing, templating, and persistence. Django also has stellar documentation and an established community.

  • TurboGears defaults to best-of-breed libraries, which apparently are Paste, object dispatching, Genshi, and SqlAlchemy. This philosophy produces a better all-round toolset, but at the risk of instability - because it means throwing away backwards compatibility if and when better libraries appear.

Nikhil Chelliah
That's a lot of buzzwords and framework names to contend with! Yikes!
Jarret Hardie
Welcome to open source technology stacks. Nothing exists by itself.
S.Lott
+1  A: 

Besides what Nikhil gave in his answer, I think another minor difference is that Turbogears provdes some support for javascript widgets and integration with Mochikit.

Whereas Django steadfastly remains javascript framework neutral.

(At least this was true with older versions of Turbogears... this might have changed with TG2)

Edit: I just went over TG2 documentation and see that it did indeed change. Turbogears now uses ToscaWidgets which can use jQuery, ExtJS, Dojo, etc. underneath. This nicely makes it more framework neutral while still providing nice javascript widgets.

This strikes me as a pro for Turbogears if you don't have any javascript experience and a pro for Django if you are writing a lot of specialized javascript.

Van Gale
I am guessing you could just ignore TG2's javascript integration and write your own exactly as you would with Django, so shouldn't be a disadvantage if writing specialized javascript.
Ali A
Possibly, but then you might have to pick another form library too. In other words, I'm not sure if tosca forms will work without tosca widgets.
Van Gale
ToscaWidgets JS is a simple convenience and it's totally optional. For example I got several TG2 project that don't use TW versions of the libraries and they work without problems. As for your last comment it's totally irrelevant TW is split into several packages, you pick what you want and ALL the JS is optional.
Jorge Vargas
A: 

Because Django uses its own ORM it limits you to learn that ORM for that specific web framework. I think using an web framework with a more popular ORM (like SqlAlchemy which TG uses) increases your employability chances. Just my 2 cents ..

hyperboreean
But you don't have to use the Django ORM. You can, for example, use SqlAlchemy in Django.
Brian Neal
What's the point of using SqlAlchemy with django, if only creating more works?
jpartogi
@Brian Neal, you meant he branch that was put in the attic or the third party one developed by only one guy? I reallly suggest you back up your claim with some code.
Jorge Vargas
+1  A: 

One of the most important questions is not just what technical features this platform provides or that platform provides, but the driving philosophy of the open source project and the nature of the community supporting it.

I've got no dog in this fight myself, but I found Mark Ramm's talk at DjangoCon 2008 to be very interesting on this point (Google will yield no end of subsequent discussion, no doubt).

zweiterlinde
A: 

Last I checked, django has a very poor data implementation. And that's a huge weakness in my book. Django's orm doesn't allow me to use the power of the underlying database. For example I can't use compound primary keys, which are important to good db design. It also doesn't support more than a single database, which is not a big deal until you really need it and find that you can't do it without resorting to doing it manually. Lastly if you have to make changes to your database structure in a team-friendly way, you have to try to choose between a set of 3rd party migration tools.

Turbogears seems to be more architecturally sound, doing its best to integrate individual tools that are awesome in their own right. And because TG is more of an integrator, you're able to switch out pieces to suit your preferences. Don't like SQL Alchemy? You can use SQLObject. Don't like Genshi templates? You can use Mako or even django's, although you're not exactly stuck with the default on django either.

Time for tg2's cons:

  • TG has a much smaller community, and community usually has its benefit.
  • Django has a much better name. I really like that name ;-)
  • Django seems simpler for the beginning web developer, with pretty cool admin tools.
  • TG has decent documentation, but you also need to go to Genshi's site to learn Genshi, SQL Alchemy's site to learn that, etc. Django has great docs.

My 2 cents.

django doesn't require you to have a database. You can set sessions, auth etc to use other backends. Using N databases is pretty easy as long as you don't have related data between them, which sucks.
Vasil
I was referring to this: http://code.djangoproject.com/wiki/MultipleDatabaseSupportIs it out of date now or not the complete picture?The part about requiring a database came second hand, and was a while ago. I'll edit that out.
@freelookenstein Django still does not have complete multiple database support, certainly not to the extent that SQLAlchemy has it (sharding, etc). However, I find it far easier to use SQLAlchemy with Django than to deal with the TG2/Pylons/Paste ecosystem.
AdamKG
Oh, and Django's limited multiple database support is not in the released version (1.0). I believe at least parts of it are slated for 1.1, later this month.
AdamKG
+13  A: 

TG2 has several advantages that I think are important:

  • Multi-database support
  • sharding/data partitioning support
  • longstanding support for aggregates, multi-column primary keys
  • a transaction system that handles multi-database transactions for you
  • an admin system that works with all of the above
  • out of the box support for reusable template snipits
  • an easy method for creating reusable template tag-libraries
  • more flexibility in using non-standard components

There are more, but I think it's also important to know that Django has some advantages over TG2:

  • Larger, community, more active IRC channel
  • more re-usable app-components
  • a bit more developed documentation

All of this means that it's a bit easier to get started in Django than TG2, but I personally think the added power and flexibility that you get is worth it. But your needs may always be different.

Mark Ramm
+3  A: 

Pros.

  • SQLAlchemy > django ORM
  • Multiple template languages out of the box (genshi,mako,jinja2)
  • more WSGI friendly
  • Object Dispatch > routes > regexp routing. You can get the first 2 with TG2
  • Almost all components are optional you can keep the core and use any ORM, template, auth library, etc.
  • Sprox > django forms

Cons. - Admin is more basic (no inline objects yet!) - less third party apps - "app" system still in the making. - given it's modularity you need to read documentation from different sources (SQLAlchemy, Genshi or Mako, repoze.who, Pylons, etc.)

Jorge Vargas
+1 for Sprox - Never heard of it before, but it seems to rock !! (just check the tutorial on the project's site)
Martin
+1  A: 

I was struggling with the same question months ago and decided for Turbogears 2, and my reasoning was simple. "I'm new to python, I want to learn it not just for web-projects but as a substitute to php for scripting small helpers"

What I didn't like about Django, to me looks like a "close platform". ORM, Template system, sessions, etc they all are Django's

On the other hand, Turbogears 2 uses already known open platforms and just glued them, just like Appfuse does it for Java

With TurboGears 2 I learn SQLAlchemy that I can use later for small python scripts, or from the python shell to solve common tasks.

Main drawbacks are the lack of complete documentation and error messages.

Sometimes you have to search very deep to find simple solutions, the learning curve is steep, but it pays long term. The error messages where to me very confusing (coming from more than 10 years in Java development). I had lost many hours trying to find an "ascii encode error" when the real problem was a module not being imported.

That's my opinion, just remember I'm new to python and I could be wrong about many things stated here.

Juparave