Django and Development Speed
Posted on July 22, 2010Warning, this post is boring, don't read it. No jokes, it is boring
If you have been following my every move for the last year (???) or so, then you'll know that I first built Sandcurves with PHP. I actually loved it. My plan was to try to do some web development between tours, so that I could be home for longer stretches, but still guide a bit. It didn't really work, but I did manage to build a working blog with PHP.
Then I learned a super lesson in Spam. I just saw the email today where I was asking the website administrator why my space quota was full. I had been uploading my birdlist, and it couldn't take another bird's name! Some spam machine had found my super unsecured blog and email and hit them with spam. It must have happened in a really short time.
I thought I had been hacked (probably not, it was just plain old spam, by the bucket.) So I did something desperate, I just deleted the entire website and gave up.
I was sort of heart broken - here was someone who thought he could offer a service of building websites, and I failed. Totally. What bugged me the most was that it took me really, really long to build the site. I would do a little, go on tour, come back, do some more, go on tour again…
If you have ever worked on PHP before, you'll know that it can get messy. Trying to come back and understand your own code when you have been thinking about lions and sand dunes for two weeks was tough. My programming skills suck, so the code was worse. At times it was faster to delete whole files than to figure out how I was hitting the databases to pull everything together.
I had been learning Python for some time, and worked through an great book, Dive Into Python by Mark Pilgrim. Did I say it is a great book? It is getting a little out of date, but you should still read that if you plan to learn Python.
Anyway, I kept thinking that it would be so cool to develop a website with Python rather than PHP. I tried various things, including trying to figure out how to build a whole website using CGI scripts - I didn't know what I was doing. I would try one thing for a week, then read about something else, try it, get nowhere and start all over.
Es (my wife) and I were talking about turning Frantic Naturalist into a travel agent, just for the time being, and I needed a good website for that.
I was watching the Google Tech Talks on Youtube, especially the Python stuff (some of which is still over my head), and came saw Guido talking about Django with Google App Engine
I didn't even watch the video (still haven't - I'm to stupid to understand what people with brains like his think about) and downloaded Django and started working through the tutorial. Mmmm, it was interesting and somebody sensible had written the documentation.
I did watch one video, Django - a web framework for perfectionists with deadlines
I wasn't so much hooked because of any feature of Django, it was mainly that I got the whole thing working on my computer quickly, understood the docs and, perhaps mainly, thought it was cool. That's why I liked Python in the first place, it was cool. Oh, and I like snakes… I know, Python isn't named after snakes from the family Pythonidae, but it should have been [ see ].
But (and I am getting to the point now - thanks for hanging in there) one thing he and others keep jabbering about is this "super fast" and "deadlines" and that Django comes out of the journalism world. I guess I just didn't take that stuff to heart to much, because if I could work with it a little faster than PHP, then it was going to be fast enough for me.
And it took me a while to learn. There are good docs, but there is still a lot to get right, especially if you are hosting on a shared host, where you have little control. I had to learn how to work with ssh and get better with ftp, and generally learned a lot of things relating to development. At the same time I was spending hours waiting for government people for all the papers I needed to get my business off the ground. Plus I was enjoying being a kind of 'stay at home dad'. I had gone through times at the lodge where I would leave and my boys would be sleeping, and get home at night when they were already sleeping - I hated that.
I started out a bit slow, and built views that were to complex and didn't separate the whole thing out well. But I decided I didn't want a mess like I did with Sandcurves in PHP, I wanted clean, pluggable code that is super duper fun to go back into and fix. I would work a little here, and then work a little on See Namibia. If something was getting out of hand, I would delete it, re-think the programming logic and re-build.
Now that approach is paying off. My directories are nice and neat, my code is clean, I have it all broken up into various apps and can develop some on my own computer and know that they will just work when I upload the files and re-sync the database.
For some Django developers it is great that they can leave the HTML and CSS to the web designers, but for me it is great to do the whole thing. What is so wonderfully is that when you write HTML, you are writing HTML, just with the template tags that fit so naturally into it. No PHP like logic withing the HTML. I really do love writing HTML - I write all my blog posts in HTML (you know, with the &bnsp; after each full-stop to double space, and open and close my paragraphs. I really do like writing HTML, and with the logic removed from it, it can again look good. Want to see - hit view source. I like writing the CSS as well, and organize my CSS file really well. It is all alphabetized and everything.
It may all seem a bit extreme, but once you have it like that, you can keep going back and working on things and find them with ease, and in the case of the python modules, know exactly what you were trying to do.
It is then that Django development really does become "Stupidly Quick" as Jacob Kaplan-Moss likes to say. I was a Lego fanatic when I was a kid. My parents in Kenya still have this whole trunk full of the stuff, and that's only what we didn't blow up or otherwise mutilate. Once you get over the initial learning, and start to write good DRY code, Django starts to feel like these huge things we would build as kids, where you would have this platform and just add this then and that thing to it.
Did you read all the way to here? I told you it was going to be boring. But if you are getting into this stuff, and finding learning Django a bit challenging, stick with it - once you get to the inertia phase, it is all fun.