Errata

Lightweight Django

Errata for Lightweight Django

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
ePub Page multiple
code blocks that contain "urlpatterns" definition

The format of urlpatterns is incorrect for the first sections of the book (up to page 58), thereafter the correct form is used.

The book states that it specifically pertains to Django version 1.8. For version 1.8, the Django documents state that urlpatterns should be a Python list (defined as values enclosed by square brackets). However, throughout the first part of the of Lightweight Django (from page 14 to 58), a Python tuple is used for examples of urlpatterns (a tuple is defined as values enclosed by parentheses). For some reason, after page 58, the rest of the examples for urlpatterns are properly defined as lists.

EXISTING INCORRECT CODE (e.g. page 14)

urlpatterns = ( url(r'^$', index), )

CORRECTION

urlpatterns = [ url(r'^$', index), ]

Although DJango 1.8 will not complain if a tuple is used here, instead of a list, it nevertheless represents an error from the perspective of the Django official documents on usage.

impact analysts  Dec 27, 2015 
Mobi Page ch4
Rest chapter

In the Serializers, the links field gets called as a module or class for some reason and fails.

'module' object is not callable

Commenting out the common links field of each serializer and it's corresponding key in the fields dict prevents this, so get_links is never called.
However, it remains to wonder why this is happening.

John Joyce  Feb 13, 2016 
PDF Page 1
NA

Please can you list all the versions of the software that will work with the code in this book. there are many versioning issues with the code years down the line.


Kevin Lee  Jan 27, 2018 
PDF Page 24
Example for Adding Static and Template Dirs

The setting for TEMPLATE_DIRS should be defined in TEMPLATES. It becomes
TEMPLATES=[
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
},
]
When I try to run the example in the book. I got the error that says "template not found for home.html". I change the settings like that and it worked. I am using Django 1.11.6

Vincent Dhawu  Oct 14, 2017 
Printed Page 32-33
"File/Folder Scaffolding" Section

It's not clear in this description when the startproj command should be used, what form it should take, and what the final result will be. The wording almost seems to suggest that the result of the startproj command will include the folders and files listed under the sitebuilder folder in the description.
What I think the section should do is instruct the reader to employ the following command:
django-admin.py startproject prototypes --template=project_name
Then the section should explicitly tell the reader to create the sitebuilder directory in the prototypes directory created by the above command.

Jerry Kurlandski  Nov 30, 2015 
PDF, Mobi Page 43
home.html

On the source code of home.html both the opening and closing tags of the unordered list read <ul>. The closing tag should be </ul>.

I opened a pull request to fix the code: https://github.com/lightweightdjango/examples/pull/18

Fabio Utzig  May 29, 2016 
Printed Page 48
two last text paragraphs

The paragraph uses "build" when it should say "_build", and "projects" (italicized) when it should say "project's" (normal). I.e. the two paragraphs should read:

We should now be able to run our management command to create the _build directory, which will be generated at the root level of our project's directory.
...
You should now have a _build directory located at the root level of your project with all of your static files inside. Let’s run a simple Python server locally to test our static files.

Jerry Kurlandski  Nov 03, 2015 
PDF Page 49

The .pdf version seems to have corrected a couple of issues in the printed version, but in the pdf version there is a small typo. The line which reads "os.makedirs(settings.STATIC_ROOT, exists_ok=True" should read "os.makedirs(settings.STATIC_ROOT, exist_ok=True." Without this correction you get "TypeError: makedirs() got an unexpected keyword argument 'exists_ok'" at the command line.

Jerry Kurlandski  Nov 03, 2015 
PDF Page 49
Code for Building Single Page

Django 1.11.6
The Command class should implement the add_arguments methods from BaseCommand or it could result in error that says arguments doesn't exists.
def add_arguments(self, parser):
parser.add_argument('page', nargs='*', type=str)

so the first `if` part on method def handle(self, *args, **options) would be like this:
if options['page']:
pages = options['page']
available = list(get_pages())
invalid = []
for page in pages:
if page not in available:
invalid.append(page)
if invalid:
msg = 'Invalid pages: {}'.format(', '.join(invalid))
raise CommandError(msg)
The rest just the same. (Like the errata from Mark Lavin, also on the same page).

Vincent Dhawu  Oct 14, 2017 
ePub Page 134
3rd line

The line reads:

`os.makedirs(settings.STATIC_ROOT, exists_ok=True)`

Should read:

`os.makedirs(settings.STATIC_ROOT, exist_ok=True)`

You'd get the exception `TypeError: makedirs() got an unexpected keyword argument 'exists_ok'` when running the build.py management command.

Eric Lagasca  Aug 25, 2017