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.

CheeseRater

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.

DjangoSnippets.org

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.

Besides the source for Cab, James has also released django-registration, a “simple, portable, generic user-registration application for Django projects.” It follows a common registration parttern:

  • 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.

Comments

  1. 001 // BearXu // 02.25.2007 // 8:51 PM

    Thanks Jeff to introduce these great but unknown apps. I love django’s app, so I hope the DjangoTeam will build a app repository soon and hope the team will visit China to give us nice keynotes

  2. 002 // Jacob Kaplan-Moss // 02.26.2007 // 12:31 AM

    Thanks for the nice writeup, Jeff, and double-plus thanks for the cooool design. It’s gotten a number of props here at PyCon.

  3. 003 // Nicola Larosa // 02.26.2007 // 12:38 AM

    Jeff, the link to Cab is broken (the “c” should be lowercase).

  4. 004 // Jeff Croft // 02.26.2007 // 12:55 AM

    Thanks, Nicola — I’ve fixed it. :)

  5. 005 // Robbin Bonthond // 02.26.2007 // 1:57 AM

    Thank you all very much !

  6. 006 // michele // 02.26.2007 // 5:32 AM

    eh… nice sites, nice ideas… but… where’s openid? :(

  7. 007 // Bjorn Kristinsson // 02.26.2007 // 7:41 AM

    Nice, but am I the only one who get’s a lovely Mod_python error on djangosnippets?

    I tried to register this morning and got that error when I submitted.. have been unable to access the site since :\

  8. 008 // Kai Kuehne // 02.26.2007 // 10:14 AM

    No, you’re not the only one. ;)

  9. 009 // Jeff Croft // 02.26.2007 // 10:30 AM

    Yeah, looks like James has a little syntax error on his site. It was working last night, so he must’ve broke something along the way. I sent him an e-mail to let him know, but he’s at PyCon right now, so I’m not sure how busy he is — might take him a bit to get to it.

  10. 010 // Baxter // 02.26.2007 // 11:55 AM

    It’s back (and sweet!). I keep thinking about making my source available, but I’m too embarrassed.

  11. 011 // Alberto // 02.26.2007 // 3:02 PM

    Great news! Django Snippets is a dream comig true for every Djangonaut. I would suggest only a little change in the snippets.css file:

    #content #main div.highlight pre {
        font-family: "Consolas", "Bitstream Vera Sans Mono", "Andale Mono", "Courier New", monospace;
    }
    

    Consolas is the beautiful monospaced font shipped with Windows Vista. In fact many users are currently installing Consolas also on Windows XP machines.

    Courier New is a dying out font (finally!)

  12. 012 // Jeff Croft // 02.26.2007 // 3:14 PM

    Alberto-

    Consolas is indeed my favorite monospaced font (and the one I use here). However, I don’t have any control over the DjangoSnippets.org CSS — that’s all James Bennett. Perhaps he will see your suggestion, though.

  13. 013 // Jay States // 02.27.2007 // 9:29 AM

    Jeff… I started down the road to Django because of this site and now these example help me over 1000%! Thanks, I’ve switched to Python and Django after 3 days of using it over php 5.

  14. 014 // radek // 02.27.2007 // 9:47 AM

    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).

    +1

    PS: Jeff, please, make the TAB order in the comment form flow from Your URL field directly to Your thoughts field. I always wonder thet I cannot type over Markdown hyperlink ;)

  15. 015 // mary // 02.28.2007 // 2:07 PM

    I just need to know where can i find your source code for the django project as i am interested in it

    Thank you in advance; Mary Adel

  16. 016 // Jeff Croft // 02.28.2007 // 2:15 PM

    Mary, the source code for The Django Project website is available at:

    http://code.djangoproject.com/browser/djangoproject.com

  17. 017 // Soltys // 03.01.2007 // 3:09 AM

    From LOST-theories.com code i learn a lot, about Django. Thanks. Ps. I don’t like Lost serial :)

  18. 018 // mark // 03.06.2007 // 1:09 PM

    Thanks for this! This should help SO MUCH!

  19. 019 // Scott Benjamin // 03.07.2007 // 3:02 AM

    The Django community is really starting to ramp up. I love to see how people implement their sites with using it. It has really helped me branch out and think about solutions in an entirely different light.

    Thanks!

  20. 020 // Stevem // 03.23.2007 // 2:02 AM

    Why do you insist on using Helvetica when it looks so utterly pants on a PC?

    Admittedly Helvetica isn’t standard on a PC but some of us do have it and it looks rubbish. I don’t know what it looks like on Vista though…

  21. 021 // Bret // 06.10.2007 // 11:42 AM

    Didn’t they mean CheeseRatr?

  22. 022 // Gaurav // 08.21.2007 // 5:23 AM

    hi, just downloaded cheeserater,its amazing.. just one addition, taking a note of django revision 5172 there w’ld be changes in the votes model.. need to import generic from contrib.contentypes ..

    thanx!

  23. 023 // Mike // 06.30.2008 // 9:16 PM

    I realize this is like a year old, but I just wanted to say THANKS for a new Django developer :)

Post your comment