Over the past two months I’ve been building a fairly straightforward database-driven application for a client. Originally we were going to code it in PHP, then I started looking around at some of the newer application frameworks out there. Ruby on Rails was considered, but Django really got my attention as it is Python-based, and I have a soft-spot for Python.

Yesterday, my client requested a series of changes be made to records in the database. Nothing too nasty, just adding prefixes to certain fields, renaming a few others based on the contents of another field, etc. Django made it simple.

For example, to prepend “ns-” to the name of every Novell server in the database:

from servers.model import Server
server_list = Server.objects.filter(os_architecture = “novell”)
for server in server_list:
    server.name = “ns” + server.name
    server.save()

I know, it’s a simple example and easily done in other languages and frameworks. I just like the fact that I could do it in Python, quickly.