Practical Django Projects source code

I’ve recently been working my way through Practical Django Projects, Second Edition, by James Bennett, published by Apress. It’s good but, despite promises, the finished code isn’t available online. So I’ve bunged my finished code on Bitbucket.

James Bennett has his own repository but, at the time of writing, his example code seems to have stalled early on in the book. It can be a struggle to get the book’s code working. There are various errors which mean some of it doesn’t work as written. Plus some third party code has changed how it works since the book was published. And several templates are left as an exercise to the reader, merely referring to non-existent online examples.

I was surprised how few examples of I found online of people asking for help, or explaining how they got things working, so hopefully this (working) code will help others. Brett Haydon also has some useful chapter-by-chapter notes on the first edition of the book, which is worth a read too.

I should add that I didn’t write this code with the intention of making it public so, as with anything typed in as a tutorial from a book, it’s lacking all the helpful comments I’d usually include. But if you’re following along with the book and get stuck, hopefully it’s a help.

Comments

  • Hi,
    I also think that the code samples provided with this book are far from complete and leave much to be desired. Luckily, people like you actually care enough to provide the rest of us with assistance.

  • Thank for posting your code, Phil. It has been a *tremendous* help. I notice that your coltrane/feeds.py file is missing. The pyc file is there though.

  • Thanks Mitch, I'm not sure how that disappeared -- I don't seem to have a copy anywhere.

    Another thing... Someone on Twitter said the "link_detail.html template should reference objects.etags vs object.tags". I don't have a working copy at the moment, so can't check, but something to try if things don't work as expected.

  • Mitch sent me the missing feeds.py file for the coltrane directory, and it's now included in the source files on Bitbucket. Thanks Mitch!

  • Thank you so much!!! Was just about to start tearing my hair out. Good job man!

  • So glad to find your code. Still having trouble with the link_detail.html template, however. It doesn't seem to recognize the tags. Can you clarify the comment you made earlier about referencing objects.etags?

  • Addendum to prior post: This works:

    {% if object.etags.count %}
    This link is tagged with
    {% for tag in object.etags %}

  • Great, thanks Anthony - I've made that change to the template on BitBucket now.

  • I found the link to this by googling different django book names, trying to find reviews of books to read. I need to find a book (or a person) to teach me enough of Django so I can actually make something useful with it. I've dabbled a bit and managed to build a simple web site that uses LDAP authentication and such, but what I'm looking for is something to help me better understand how projects/apps work in Django, when I should split something into an app, how I can interact between different apps, and how I can use all the widgets and other nice functionality that's obviously in there already - the admin site uses it. I really, really hate re-inventing the wheel, so I'd rather just use the calendar widgets and such from the admin site on my own site, at least to start with. It shouldn't be too hard to do some simple additions/modifications to them, but my web development is nowhere near rapid as long as I can't actually use what's in there.

    Is the mentioned book something I should read, or is there some other book that would serve my purpose better? Or if there's a web site where I can actually ask and get answers to my question would be even better. I've googled for days and days and haven't really found anything useful enough so far :(

  • The book was good and is well worth a read.

    You could also try The Django Book, which is free and online, the Django documentation, which is very good, and the Django-users mailing list, where you can ask questions.

    I've assumed that things like the calendar widgets in the admin site are jQuery calendars, so there's nothing specifically Django about them.

  • Wow, this is amazing... thanks! I've been struggling with the source code linked to from the Apress page, which is incomplete and largely incorrect. It's fantastic to finally find yours! The book (2nd ed.) also seems to have a bunch of errors, but I've learnt a great deal from it all the same.

    Cheers

  • How to start that project? There is no manage.py, settings.py under the root. Found them under cms, but when starting:

    python manage.py runserver
    Error: No module named cab

    I'm not a dev, just started django learning.
    Thanks

  • Sorry andriy, it's been ages since I've looked at this code or the book, so I can't really help with the precise problem. I'd recommend working through the book step by step and just using my code examples as reference.

  • ok. now after book examination is done i see that my previous question was really stupid :) thanks for the great job, Phil.

  • Thanks Phil - the "@models.permalink" thing in "def get_absolute_url(self):" was driving me to distraction (it is all still spells and incantations to me) but you got it working for me.

Commenting is disabled on posts once they’re 30 days old.

14 Jan 2010 at Twitter

  • 4:51pm: Woolly hat over ears, in-ear headphones, 2003 Plump DJs Essential Mix vs the sound of a loud, tinny conference call.
  • 3:17pm: Woolly hat over ears, in-ear headphones, 2003 Plump DJs Essential Mix vs the sound of men drilling a door into a wall.
  • 2:18pm: @gilest Coincidentally I'm about to try and work out how to have the @pretendoffice RSS feed include the full text. Fingers crossed...
  • 9:00am: Even after yoga, breakfast and shower, the urge to spend all day in bed reading is almost impossible to resist.

14 Jan 2010 in Links

Music listened to most that week

  1. God Help the Girl (10)
  2. Stereolab (7)
  3. Ash (7)
  4. The Clash (5)
  5. The Velvet Underground (5)
  6. Pulp (4)
  7. Babybird (4)
  8. The Shins (4)
  9. Lou Reed (4)
  10. Traxmen (4)

More at Last.fm...