You are invited to Log in or Register a free Frihost Account!

Django or turbogears?


Neither one was a big deal to install. TurboGears has a very nice (or very
scary, depending on your level of paranoia) setup script that runs out and
grabs the correct versions of all the code that you'll need and installs
them. Django just tells you to check out the trunk of their Subversion tree
at the moment. Both systems want to have their code installed in the
site-packages directory, and TurboGears puts it's admin scripts in
/usr/local/bin, while Django encourages you to put theirs on your PATH.

Project Setup

Both have a Rails-like "admin quickstart" command that sets up a project
directory for you and gets the basics going. Both have a "" and a
"" file that you edit and add your model and controller code.
(I guess you would change these files into packages for doing "real" work.)

Models and Persistence

The model setup for Django requires to you inherit from a Django class. The
model setup for TG does not have that requirement, but the examples all
inherit from SQLObject. Django uses a syntax very much like SQLObject for
you to define persistent attributes. One interesting difference is that
instantiating an object in TG/SQLObject actually creates a record in the
database, Django requires you to explicitly call save(). (This pattern seems
to extend to updates, it appears that assigning a value to an attribute
causes an immediate update to the database in TG/SQLObject, but I know I saw
ways in the doc to persist multiple attributes at once.)

It does appear that the Django persistence layer has more bells-and-whistles
than SQLObject, but I also get the feeling that there's some very black
magic in the implementation, so I'd hope that nothing ever went wrong.

Both systems create your database schemas for you by parsing the models. TG
says that there's a way to retrofit an existing database to SQLObject, but I
did not look into it.


Django has you create "naked" functions to handle requests (and passes the
HTTP request object to those functions). TG has you create functions within
a class that inherits from a root controller class. Django has the
controller decide what template is to be presented to the user at runtime,
TG seems to require each controlling function to pre-declare what template
it will use thru the use of decorators.

URL Traversal

Django has you create an explicit mapping (using regular expressions) from
URL to the appropriate function. TG really didn't cover URL traversal in
their tutorial, mainly because they only had one object that you had to deal
with. (The TG demo does give you a way to take an unknown URL and change
that into a traversal.)

Project Layout

Django makes a distinction between the site and the project. The idea is
that you could create multiple "pluggable" projects and install them in a
site. TG does not seem to make this distinction.

Django also maintains the idea of two separate servers: one to view the
content and one to maintain it. This makes a lot of sense in the Django
world, see the "Extras" section. TG just creates one website and has you do
everything through that site.

Templating Languages

By default, Django uses their own templating language, which is pretty ugly,
IMHO. But since you have to invoke the template processor within your
controller functions, you can swap it out for any template language you
like. TG uses Kid, which is very similar to TAL of Zope fame.


Neither project is GA as yet, but both are going to get there "soon." The
underlying code for Django is actually in production at several sites (it is
part of a non-free CMS known as Ellington). Neither project makes any
guarantees about interfaces staying the same between revisions, at least for

Both projects have a dedicated group message board at Google. TG seems to be
getting a lot more traffic.


Django provides an auto-generated "admin" interface. When you create a model
class, Django creates a complete administrative interface to allow you to
create, read, update, and delete instances of your model classes. It's
pretty slick, but you seem to be limited to the UI that they give you (I
suppose you could hack their administrative templates, if you had the need,
but they seem pretty tightly bound to the rest of the system.)

TG's "extra" that Django does not have is the MochiKit javascript stuff for
doing AJAX in the browser (and they even use JSON for communications, so
would that really be AJAJ?). They even walk you through using MochiKit as
part of their tutorial.

Both of these systems are frameworks, without any pre-built applications,
such as a CMS, ticket tracking, or anything else.


There are some parts of both frameworks that seem to be missing, at least in
comparison to Zope/Plone. There is no search engine, and no integration with
nice Javascript editors, like Epoz or Kupu. I'm sure both of these could be
integrated, but you'll have to do it yourself.


Neither of these tutorials cover anything approaching a real-world website
(there's nothing in either on handling site structure and navigation). The
TG tutorial is very quick (it's titled "The 20 minute Wiki"), the Django
tutorial takes several hours to go through, but it covers a lot more ground.
Both tutorials gave me a pretty good introduction to the material, I'm not
sure how they reflect using the stacks in real life. The Django tutorial
does take the time to discuss the philosophy behind various design
decisions; when I finished with it I felt like I had a much better idea of
what I was doing and why. The TG tutorial was more of a
type-this-and-be-amazed feel.

Both tutorials are very much concentrated on using a relational database as
a data store; there's nothing on using other stores (filesystems, object
databases). I suppose that makes sense in an introductory tutorial.

Session Management

Django does not address session management in their tutorial, but it is a
section in their reference docs that explains how to do it. (I didn't try it
out.) Django does hint that instructions on how to handle permissions (I'm
assuming something ACL-like) in the future (and does require you to login to
use their admin server). I don't see anything referencing session management
or permissions after a cursory glance of the TG docs.


I saw that Zettai is offering Django hosting now. A quick google for
"turbogears hosting" did not return

-- chris blog
Related topics
RoR, Django & Turbogears?
django on FRIHOST
Who here has used TurboGears framework
anyone using Django??
The Start
Python Web Application Framework
has anyone hosted a django app
Ruby on Rails v/s Python in Django
Python - Django Framework in server 4?
python (django) or php
django 'ready to use' templates
Server 4 not supports Python?
Reply to topic    Frihost Forum Index -> Scripting -> Others

© 2005-2011 Frihost, forums powered by phpBB.