Django Unleashed Errata

To report errata, please email errata (at) informit (dot) com with:

  1. the name of the book,
  2. the chapter (and section/example if applicable),
  3. the page number where the error is found.

Table of Contents


Chapter 3

What requirements.txt file?

The aside on page 56 makes reference to a requirements.txt file that exists in a repository. The repository in question is the official book code hosted on GitHub.

To get the requirements file, you can either browse to the file online and then copy and paste the contents, or you can use the curl command to download the file directly to your own project, as demonstrated below.

$ curl -o requirements.txt \
    https://raw.githubusercontent.com/jambonrose/DjangoUnleashed-1.8/799c6ab6ae/requirements.txt

The requirements file is just a list of packages for pip to install. To install all the items in the list, use the command below.

$ pip install -r requirements.txt

While having a requirements file is a Python convention (to make using a project easier for other developers), you don't actually need a requirements file. You could simply install all of the tools you wish directly with pip. Below, I use pip to install IPython with notebook functionality enabled, using exactly the same name from the requirements.txt file online.

$ pip install ipython[notebook]

Note that between the time I finished writing the book and now, IPython notebooks have begun to shift to a new project named Jupyter. While the command above still works, eventually you'll want to install Jupyter with the command listed below.

$ pip install jupyter

When using just IPython, the terminal command to activate notebooks was ipython notebook. With Jupyter, that command is now jupyter notebook. However, with a Django project you will still want to access notebooks with the command below.

$ ./manage.py shell_plus --notebook

Thanks to Chris Wilkins for pointing out the ambiguity.

Invoked manage.py file has extra 'r'

The command in the aside on page 56 should invoke the manage.py file, not the manager.py file.

Thanks to Evan Palmer for catching the error.


Chapter 4

Example 4.70 (page 114) ends with the code printed below.

>>> template.render(context)

As noted in the IPython notebook on GitHub, the code should actually use a print() function to make the output readable.

>>> print(template.render(context))

Thanks to Dan Hitt for catching the error.


Chapter 5

Extra Underscores in pub_date

Example 5.53 (page 154) contains the command listed below.

Post.objects
    .filter(pub__date__year=2014)
    .filter(pub__date__month=11)
    .get(slug__iexact='django-training')

There should only be one underscore between pub and date (in all of the code in the book), meaning the command should actually be the code below.

Post.objects
    .filter(pub_date__year=2014)
    .filter(pub_date__month=11)
    .get(slug__iexact='django-training')

Thanks to Charlie Pilgrim for catching the error.


Chapter 29

Disabling DEBUG Setting Disables Static File Loading

Clarification: the reason we use the whitenoise package beginning on page 733 is because Django does not serve static files in production. When the DEBUG setting is disabled (set to false in suorganizer/settings/production.py in commit 3c73f989ea) Django ceases to serve the files, instead anticipating that files will be served with another tool, because Django does not serve static files quickly. On very large sites, it is recommended to serve static files on a completely different server, usually sitting behing a Content-Distribution Network. Covering this material is beyong the scope of the book.


Index

PostgreSQL listed as PostreSQL

The index has a typo on page 798 (right column, 4 lines down) where PostgreSQL is listed without the g. It is therefore not listed in the correct position alphabetically, (appearing after entries such as PostManager, instead of before).

Thanks to Evan Palmer for catching the error.