main  /  posts  /  2006  /  dec

On Django


11 dec 06

I thought I’d take a few minutes to tell you about Django, “the Web framework for perfectionists with deadlines,” which I used to build my new site. Although I had heard of it previously (I swear) I got really introduced to Django when James got hired at World Online, the online division of the Lawrence Journal-World, where Django was developed. Frameworks encourage not only quicker development by doing a lot of the tedious work for you, but they encourage development with best practices, something I’m heavily interested in now that I’m having to go back and change/maintain code I wrote years ago.

Why Django?

Maybe you haven’t heard of Django, but possibly you’ve heard of Ruby on Rails, another framework that’s gotten a lot of press, developed by 37signals. I picked up the Rails book last year, got really excited at first, then proceeded to beat my head into the wall actually trying to use it. It’s not that Rails isn’t great, it’s that I’m no Ruby programmer and probably never will be. Although I should probably revisit Rails at some point, I can’t imagine how you’d ever do much with it without really getting into Ruby.

Django, on the other hand, is written in Python, a much, much friendlier language, at least for me, and still object-oriented. And Python is used by a small company you may have heard of: Google. Additionally, in my humble opinion, Django is about 5498345098345 times easier to use than Rails, and you can do a lot with it even without doing much programming. (I’ll have some further reading on this at the end.)

So, the blog

For a long time I’ve wrestled with using Movable Type—the rebuilding, the 45098345 database tables it creates, how technically it costs money now. I didn’t want to use WordPress, although it is my current party line as far as what blogging platform I recommend. But, being a programmer, the right thing to do at this point was custom-build something for myself. So I did.

I won’t bore you with the specifics, but getting my post archives/comments moved over from Movable Type was a lot easier than I expected, just a series of commands in my database. (Then I deleted all of the really old stuff, the most cathartic thing I’ve done in a long time.) Although I’ve been tinkering with things around here for some time, someone who halfway knew what they were doing could get a blog up with Django significantly faster.

And that’s all from me

If you’re at all interested in Django, try the polls tutorial. (Django has really excellent online documentation and a book in progress.) For an idea of what you can do with Django when you’re not even a programmer, check out Jeff Croft’s blog and specifically the post Django for non-programmers. Finally, check out Wilson Miner‘s Are you generic? on generic views (common situations Django gives you the code for, such as monthly archives or a listing page). Much thanks goes to James for answering my questions, however inane, and various others (most already mentioned) for Django/design inspiration.


suki  /  12 dec 2006  /  4:29 a.m.

thanks! for some weird reason, the RSS wasn’t updating to show this post. yay for non-programming attempts at django!

Rich  /  12 dec 2006  /  6:15 a.m.

Just how elegant or straight-forward is Python compared to Ruby? Digital Web’s article on Ruby on Rails has this snippet of code:

<% @students.each do |s| %>
<p><%= s.name %></p>
<% end %>

I don’t really know Ruby, but that looks easy enough that I know it’s a loop and I could spend a few minutes to know what it’s doing. Is the equivalent in Python any easier?

And what about hosting? A lot of the tutorials (and for Ruby on Rails) seem to be an installation on a local (or purely clean, remote) system. If it’s already installed, how do you go about calling the installation? Or make templates?

P.S. I miss the live comment preview.

Simon Willison  /  12 dec 2006  /  6:39 a.m.

Rich: That’s not pure Ruby code, it’s embedded Ruby - Ruby embedded in HTML. That said, the Django equivalent (which uses its own template language with syntax inspired by Python) would look like this:

{% for s in students %}{{ s.name }}{% endfor %}

In pure Python, for loops tend to look like this:

for s in student:
    print s

Mark  /  12 dec 2006  /  8:01 a.m.

As a long time MT user, and one who is still languishing at version 2.66, I would be very interested in a more detailed review of what your Django blog management system looks like.

C  /  12 dec 2006  /  11:33 a.m.

I suppose this is more attributable to your design, but I love the cleanness (is that even a word?) of the whole thing. It seems to move quickly and it just looks nice.

cristinamarie  /  13 dec 2006  /  9:40 p.m.

It all sounds complicated and I understand none of it, but it looks fab.

very oddd  /  14 dec 2006  /  6:51 p.m.

Very nice and good work on building your own!


ponybadge

© 2000-2008 Maura Chace. Views expressed do not necessarily reflect those of my employer.
about  /  posts  /  photos  /  bookmarks  /  links  /  feeds  /  search  /  25 Wishes
Hosted by WebFaction. Powered by Django.