Back in June of 2006, I created LOST-theories.com, one of my first Django-powered sites. Because it seemed like it might be useful for people who were trying to learn Django, I released the source code for the site — not so much for people to take and use directly, but so people would be able to see how a Django site was built, from the ground up. I had no idea it would be so popular. I still get e-mails every week from people thanking me for giving them a complete example.
But I always felt a little sketchy about it. I’m not a great programmer by any means, and I was even worse then. If I were re-doing LOST-theories.com today, a lot of the code would be different. I’ve thought about taking the code offline for that reason. But, I’ve left it, because it seems like people really, really needed some full-site examples of Django code.
Well, this past week, two different Django-powered sites were launched with full source code available. What’s more, they were both created by far more accomplished programmers than me. And what’s even more, both of them sport designs that I had something to do with.
The first site, CheeseRater, was created by Jacob Kaplan-Moss (one of the lead developers of Django) as part of a presentation he was giving at PyCon last week. The concept is a simple one: CheeseRater lets you rate Python projects and libraries from the Cheeseshop, a popular repository of such things. It’s a really nice example piece for doing Digg-style +/- rating systems.
Jacob asked me to help make his presentation project a bit prettier, so I whipped up a very quick Photoshop mockup for him and he handled the CSS and XHTML from there.
Check the footer of the site for a link to the source code, all tar’d up nicely for your perusal and appropriation.
Perhaps even more interesting to Django developers old and new is DjangoSnippets.org, the brainchild of Django release manager James Bennett. It’s a pastebin-style app, written in Django of course, for storing and sharing snippets of code for use in your Django apps. So, not only is the source for the site itself available, but you’re also likely to find snippets on the site that will be useful to you in learning Django. For example, Jacob posted a template tag I’d be bugging him to write for a while, and I posted a Django version of Shaun Inman’s “widont“, for avoiding typographic widows. James describes the web app, which he calls “Cab,” as follows:
Cab (named for Cab Calloway) is a simple Django-based application designed to make it easy for a team, or a community, to share code snippets, while providing plenty of useful features:
- Friendly syntax highlighting of code snippets.
- Grouping of snippets by author, by language and by tag.
- A bookmarking feature to help users track snippets they find useful.
- A rating system which tracks the top-rated snippets.
- Easy download of any snippet as plain text.
- A user signs up for a new account, which will be inactive by default.
- An email is sent to the address they used to register, containing an activation link.
- Once they click the activation link, they account becomes active and they can log in as normal.
LOST-theories.com handled registration the same way, but there are many reasons why James’ django-registration does it much better. You can imagine how a generic registration app like this will be useful in many web apps (I’d even assert that it might be a candidate for
django.contrib, the package of add-on apps included with Django itself).
As with CheeseRater, I helped James out by doing a quick Photoshop comp, which he then pieced together with XHTML and CSS. I wouldn’t call either one of these sites my greatest design achievement, but I think both designs work and are appropriate for the project.
And don’t forget…
The official Django website, djangoproject.com, has made its source code available since day one. It’s another great example of how a site is built with Django from the ground-up. It even includes a basic blog application.
What’s the point?
The point is that LOST-theories.com isn’t the only site out there offering its source code for you to learn from. There are at least three sites now offering code written by much greater programmers than myself. If LOST-theories.com’s code has been useful to you, that’s awesome. I’m glad I could help. But, I think it’s safe to say you’d be much better off using these guys’ examples if you’re trying to learn how to build a Django site.
I just wanted to make sure you knew about them.