Blue Flavor

Needle and EMP by Jeff Croft

Django: A flexible choice for your site’s CMS

December 3rd, 2007 at 1:24 p.m.

In my last post here at the Blue Flavor blog, I discussed the need for a good content management system (CMS) for most modern websites. Although there are many pre-packaged CMS choices, building one specifically to meet the needs of your site is always an attractive option. Django (pronounced “JANG-go”) is a rapid web application development framework, built on the popular programming language Python, designed precisely to make the building of custom CMSes easier and faster than ever before.

A bit of history

Django was developed at The World Company in Lawrence, KS—a newspaper company widely recognized as one of the most innovative new media outfits in the country. It began in 2003 as part of a project to build the next great newsroom CMS. In the summer of 2005, The World Company split the CMS project into two components: Django, an open-source, generic framework for building web applications (and especially CMSes), and Ellington, a commercial CMS targeted at news companies, which was built using Django.

Two years later, Django is by far the most popular web app framework for Python, and, along with Ruby on Rails, is helping to shape the face of modern web development. It has received much praise from Python creator Guido Van Rossum, and is in use at some of the world’s most recognizable Internet, media and technology companies. A few of Django’s more familiar users include Google, HP, The Onion, and The Washington Post.

Python, the language Django is written in, is also well-represented at the highest levels of Internet stardom, as it’s the language powering YouTube, and it comes bundled with nearly every Unix and Linux operation system, as well as Mac OS X.

Is Django a CMS?

Django itself is not a CMS, or any sort of “turnkey” product. It is, rather, a set of tools which allow one to build turnkey web solutions.

However, Django was born out of the content-heavy world of news media, and therefore does include several key components which makes it well-suited to the building of CMSes. Among these are an automatic admin interface (for allowing trusted users to add, update, and delete content) and a simple library for RSS and Atom feeds of your content. Many web application frameworks do not include these kinds of CMS-oriented pieces.

Because Django is not a turnkey CMS, it does have a learning curve, and does require some development time to be invested before anything of significance is created. However, the time required to build a CMS using Django is drastically less than building the same CMS without Django.

When should I use Django?

Django is suitable for building web apps of nearly any type. It has been used to build CMSes (such as Ellington, in use at over 50 news sites worldwide), social networking sites (such as Pownce), and much more. Django excels at content-heavy sites—especially those in which a set of trusted users (administrators or moderators) will be allowed access to an administrative area to edit content. Django also excels at sites which make heavy use of structured data (see my previous post for more on this concept).

Django should probably be on your short list of solutions for any custom web application. If your needs are met by pre-packaged systems, you may have no use for Django. But, if you find your site limited by the restraints of systems you didn’t build, you may want to consider Django, as well as other rapid application frameworks like Rails (for Ruby) and Cake (for PHP).

Django can also provide a nice “in-between” for those looking for a pre-packaged solution as a starting point, but who want to be able to customize and extend that product without limitation. Besides the commercial Ellington suite, there are tons of available Django apps published as open-source projects on Google Code. Many of these are designed to give you a great headstart in development, but also to be customized and extended to your heart’s content.

Django’s pluggable application philosophy

One of Django’s core design concepts is a separation between projects and applications. A project, in Django parlance, is a container for applications, as well as settings and configuration information for a particular site. Applications, then, are packages that each provide just a few specific functions. For example, the web site for a typical web design firm might contain five different applications: a portfolio tool, a blogging tool, a staff bios tool, and a contact form. Each of these would be separate applications contained in a single project, and they may or may not be dependent on one another (for example, the portfolio tool may rely on the staff profiles tool to get information about the individuals who worked on a given project in the portfolio).

Because of this “pluggage” application philosophy, many companies—especially those who run multiple websites—end up building a library of Django apps they can “pull in” to a new project as needed. You may build 10 apps, and find that one site needs just three of them, another needs seven, and yet another uses all 10. This allows for a great deal of code reuse, and a sense that you’re not “recreating the wheel” on every project.

Prerequisites for building apps with Django

If you’re interested in building your own applications with Django, you’ll want to start by having a solid understanding of Object-Oriented Programming (OOP) concepts. Django is heavily Object-Oriented. You should also familiarize yourself with Python. It’s a relatively simple language to learn, especially if you’re already familiar with OOP in other languages such as PHP, Ruby, or Java.

You can build simplistic Django applications without having a very strong understanding of OOP and Python, but you will find yourself limited and need to learn more if you wish to build more advanced solutions.

A terrific resource for learning Python is Mark Pilgrim’s book Dive Into Python. It’s available for free online, or as a printed book from Apress.

Getting started

The best place to jump in and get started is the official Django project website. There’s an installation guide and a tutorial that will walk you through writing your first app. Beyond that, there’s online documentation that bests that of almost every open-source project out there, and yet another free book that is really, really great.

You may also want to get to know the fine folks in the Django users mailing list and/or the Django IRC channel.

Once you’re ready to put your project online, be sure to check out the official list of Django-friendly web hosting companies.

In conclusion

Django is a very useful framework for developing many types of websites, but especially for building custom-tailored Content Management Systems. Blue Flavor provides Django services and has built successful Django-based CMSes for clients. If you’re in need of a custom CMS solution, it should definitely be on your short list of development environments—it certainly is on ours.

Jeff Croft

More Information