Tag Archives: Django Vs TurboGears

DJANGO VS TURBOGEARS

Django Vs TurboGears

Python is not short of packages and Web frameworks. The main aim of Web frameworks is to save the user effort of writing infrastructure code while developing a non-trivial code. Do you really want to write a code while working with different types of databases? Let’s look at the top frameworks and see the major differences between the two frameworks.

TurboGears

TurboGears is a Python web application framework which consists of many modules. It is designed in the MVC architecture that is similar to Ruby on Rails and Struts. TurboGears are designed to generate rapid web application development in Python to make it much easier and more endurable. TurboGears follows the Model-View-Controller paradigm and the modern frameworks like Rails, Django, and Struts.

TurboGear is built on top of best-of-breed open source components including Pylons, SQLAlchemy, Genshy, and Repoze. Pylons provides the controller mechanism, whereas Genshi provides the view through HTML/XHTML templating and SQLAlchemy looks after the model. TurboGears lets the user create single file applications or Web services in minimal mode and then switches to full-stack projects for a more complex website.

Advantages of TurboGear

  • TurboGear supports multi-database.
  • It consists of longstanding support for aggregates and multi-column primary keys.
  • It consists of a transaction system that handles multi-database transactions for the user.
  • Out of box support for reusable template tag libraries.
  • TurboGears is more flexible in using non-standard components.
  • TurboGears creates an easy method for creating reusable template tag libraries.

Below is the sample code for TurboGears

from wsgiref.simple_server import make_server
from tg import expose, TGController, AppConfig

class MyController(TGController):

@expose()
def index(self):
return ‘Hello World TurboGears’

config = AppConfig(minimal = True, root_controller = MyController())
application = config.make_wsgi_app()

print “Serving on port 8080…”
server = make_server(”, 8080, application)
server.serve_forever()

Django

Django is a web development framework that assists in building and maintaining quality web applications. Django helps to exclude repetitive tasks making the development process easy and a time-saving experience.

Design philosophies of Django

Django comes with the following philosophies.

Loosely coupled: The major aim of Django is to make each element of its stack independent of the others.

Fast development: The main philosophy of Django is to facilitate hyper-fast development.

Clean design: Django strictly maintains a clean design throughout its code and makes it easy to follow best web development practices.

Advantages of Django

Object Relational Mapping (ORM) support: Django furnishes a bridge between the data model and the database engine, and supports a huge set of database systems including MySQL, Oracle, Postgrens, and much more. Django also supports NoSQL database through Django fork.

Multilingual support: Django supports multilingual websites through its in-built internationalization system. So that a user can develop their website which would support multi languages.

Framework support: Django has built-in support for Ajax, RSS, Caching and other frameworks.

Development environment: Django comes with a lightweight web server to facilitate end-to-end application development and testing.

Below is the sample code for Django

from django.http import HttpResponse
from django.views import View

class GreetingView(View):
greeting = “Good Day”

def get(self, request):
return HttpResponse(self.greeting)