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
Commenting is disabled on posts once they’re 30 days old.
Igor Ganapolsky at 24 Feb 2010, 8:48pm. Permalink
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.
Mitch Fournier at 14 Mar 2010, 6:46am. Permalink
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.
Phil Gyford at 25 Mar 2010, 9:56pm. Permalink
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.
Phil Gyford at 27 Mar 2010, 4:49pm. Permalink
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!
Darren at 20 Sep 2010, 3:55pm. Permalink
Thank you so much!!! Was just about to start tearing my hair out. Good job man!
Anthony DeBarros at 26 Sep 2010, 1:34am. Permalink
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?
Anthony DeBarros at 26 Sep 2010, 2:51am. Permalink
Addendum to prior post: This works:
{% if object.etags.count %}
This link is tagged with
{% for tag in object.etags %}
Phil Gyford at 26 Sep 2010, 9:03am. Permalink
Great, thanks Anthony - I've made that change to the template on BitBucket now.
Ari Kangas at 29 Oct 2010, 7:23am. Permalink
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 :(
Phil Gyford at 30 Oct 2010, 2:26pm. Permalink
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.
John B at 14 Nov 2010, 12:58am. Permalink
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
andriy at 3 May 2011, 1:04pm. Permalink
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
Phil Gyford at 3 May 2011, 1:16pm. Permalink
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.
andriy at 4 May 2011, 12:32pm. Permalink
ok. now after book examination is done i see that my previous question was really stupid :) thanks for the great job, Phil.
Richard at 6 Jun 2011, 4:12pm. Permalink
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.