Django as an Alternative

After really looking back and forth regarding WordPress and Drupal I decided to look around at different development frameworks just for giggles and ran into Django (pronounced jango) again. I have run across Django before and usually eliminated it immediately because it is Python based instead of PHP. But for what ever silly reason… uhm, yeah, PHP using the backslash (\) for namespaces… instead of throwing Django out, I took a look at it, just to remind me why I didn’t like Python.

I can sum up my general discomfort with Python in one word, “spaces.” Python uses indents as its primary structure and highly relies on/recommends spaces instead of tabs for those indents. I find myself always messing stuff up when I use spaces instead of tabs, one too many, one too few. Oh, not when I first write the code, the text editor does take care of that but when I come back to the code and start making modifications. spaces always messes me up.

And those spaces are important since Python uses indents instead of braces for organization… let me give an example of traditional code which will look ugly because I will do what it lets me do first then the same thing in python:

if(true) { do this; do that; } else { do the other thing; }

if true:
    do this
    do that
    do the other thing

Now some would say the python way is “cleaner,” easier to read. Well, I could have made the first example with multiple lines, indents and organized it very similar to Python, and I always do so it would look almost exactly the same except for the braces ({}).  Python however enforces that type of structure of multiple lines and indents unlike say PHP which relies on the braces to know what it is doing so you can write ugly code as in the example. I like the comfort of the braces for the structure, it really emphasizes what is what. But really, once you get used to writing in in a particular language, it feels natural and eventually even “the right way.” So Python could eventually feel as comfortable as PHP. But using those darn spaces instead of tabs will always get me.

So, Python hasn’t become the stumbling block that it might have been in the past. I have been playing a lot with Django. There is a lot to like about it, some things I am not sure about, but in an odd way, it may become the thing for which I have been looking… at least for more complex web development. It works well with PostgreSQL as well as other DBs. It makes doing database stuff easy… you can almost forget SQL except maybe for real complex queries. It has a bunch of pre-made apps… yeah, the terminology gets a bit “different” at times… but Django is really designed to help a developer quickly develop custom apps to flesh out a particular website.

In Django, you start with a “project” which in my mind equals the dynamic part of the website. Static stuff like images, css, etc may actually be served outside of the project, even from a different web server. Each project then has multiple apps. Each app has a specific purpose within the project/website.

Who knows where this will eventually lead but I am finding myself liking Django a lot because I suddenly feel like the straight jacket is a lot less constraining… or maybe the padded cell is a lot larger. I am sure as I work with it more, there will be things I won’t like and who knows, eventually I could end up back working with Drupal after all (WordPress will probably always be somewhere in my toolbox). But for now, it has my attention and I am having fun playing with it.

Leave a Reply