Skip to content

Latest commit

 

History

History
161 lines (123 loc) · 7.15 KB

README

File metadata and controls

161 lines (123 loc) · 7.15 KB

Practical Django Projects (second edition)

This is the source code for the applications covered in the second edition of "Practical Django Projects", published by Apress. If you do not have a copy of the book, this code may or may not be useful to you as a guide to learning Django, as all explanations of this code and the rationale behind it is contained solely within the text of the book.

Obtaining a copy of Django

The second edition of "Practical Django Projects" was written with the upcoming Django 1.1 release in mind. However, the final release date of Django 1.1 will occur after the publication of this edition of the book. Until Django 1.1 is released, you will need to visit the Django download page and follow the instructions for obtaining the "development version". Once Django 1.1 is released, simply follow the posted instructions for downloading and installing it.

Also, note that Django development is an ongoing process and new releases of Django will be issued from time to time. If you are starting on the second edition of "Practical Django Projects" and the latest Django release is newer than 1.1 (e.g., Django 1.2, or a bugfix release like Django 1.1.1), you should download and install the latest officially-released version of Django instead of Django 1.1.

About this code

The online home of this code is at <http://bitbucket.org/ubernostrum/practical-django-projects/>, which hosts a version-controlled Mercurial repository containing the code. Chapter 11 of the book covers the topic of version control, and offers an extremely basic introduction to Mercurial; if you have Mercurial installed and would like to use it to obtain a copy of the code, simply type:

hg clone http://bitbucket.org/ubernostrum/practical-django-projects/

Initially, each changeset in the repository represents a piece of code written or changed at a particular point in the book. Each commit message mentions the page number(s) in the book to which a given changeset corresponds, and Mercurial tags in the repository mark the start and end of each chapter.

Also, it is expected that public access to this repository will be opened up before all code has been placed in the repository; if you find that you are browsing this repository before all of the code has been added, please be patient while the process of placing code in the repository is completed.

Once the full code from the book has been checked in to this repository, further changesets will represent corrections and/or updates as needed; for example, if errors are found in the code as originally printed, changesets will be added to this repository to correct them.

If you believe you have found an error in the book's code, please first check the latest copy of the code in the repository to determine whether a correction has already been made. If no correction is present in the repository, please consult Apress' errata page for the second edition of "Practical Django Projects" to view all current errata and submit suggested corrections: <http://www.apress.com/book/errata/1164>

How this code is structured

"Practical Django Projects" covers three applications: a simple content-management system, a weblog, and a social code-sharing application. All code listed in the book for these applications is present in this repository, in Python modules corresponding to the names used in the book. Thus, for example, the CMS covered in Chapters 1-3 can be found in the directory cms.

To correspond with the manner in which it is presented in the book, the cms directory contains the full project developed over the course of the first three chapters. For the remaining applications covered in the book, no project code is provided, only application code; as covered in the book's text, you should feel free to reuse the cms project for the remaining applications, or to create new projects as desired.

Templates covered in the book are present in the directory templates, organized in subdirectories corresponding to the sections of the book with which they are associated. Additional files (containing neither Python code nor templates) are present in the directory extras.

Differences between code in this repository and code in the book

To ensure that a copy of the code in this repository can be run directly with a minimum of fuss, the settings file for the cms project in this repository makes use of Python's os.path module to allow specifying the location of the SQLite database and template directory relative to the location of the cms directory. For details on this technique, consult Chapter 11 of the book.

UPDATE: Phil Gyford’s additions to "PDJP 2ed"

James Bennett, original source / repo:
https://bitbucket.org/ubernostrum/practical-django-projects/src
Phil Gyford’s additions to, changes to:
https://bitbucket.org/philgyford/practical-django-projects/src

This is an unofficial set of files for James Bennett's 'Practical Django Projects' Second Edition, published by Apress. I have no connection with the author, the book or the publisher, but in the absence of any official example files I thought my finished set might be useful.

I have tracked down fixes for most of the things that don't work from the book, and added templates where examples are missing. Most things seem to work fine for me, but I can't guarantee it will work for you. I've added a couple of things not covered in the book (like a home page for the code sharing site) to make things easier.

These files aren't designed to work as standalone applications -- they will probably need configuration and set-up, and assume you're following along with the book's tutorials and might just need a reference copy of the code.

Here are some things that don't work / might not work / will need attention:

General

  • You'll need to do some configuration in cms/settings.py
  • No SQLite database is included -- the code should create one at cms/cms.db

Coltrane

  • In the weblog app, I'm not sure if Akismet works (it doesn't complain)
  • In the weblog, sending emails after a comment is posted might not work (no complaint, but email doesn't seem to arrive when sent from my laptop)
  • The bit that sends an email notification when a comment is posted needs a template at comments/comment_notification_email.txt so I've put that outside of the templates/cms/coltrane/ directory, inside templates/cms/.
  • Setting up the tagging is problematic. This code currently works fine, but you may need to manually add the 'tags' column to your tables.
http://blog.sveri.de/2009/08/13/semi-automatic-tagging-with-django-and-django-tagging/

I can't guarantee to ever update this code or supply help with problems (I hardly know what I'm doing myself) and would welcome any thoughts on things I've done terribly wrong. Feel free to post comments here:

http://www.gyford.com/phil/writing/2010/01/14/django.php

Phil Gyford http://www.gyford.com/