The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".
The following errata were submitted by our customers and approved as valid errors by the author or editor.
Version |
Location |
Description |
Submitted By |
Date submitted |
Date corrected |
Printed |
Page xi
United States |
The book says you list "errata, examples, and additional information" on the O'Reilly catalog page for this book. However, I cannot find the example code anywhere on that page. The examples, however, are listed on the GitHub page: https://github.com/lightweightdjango/examples
|
Joshua Wedekind |
May 08, 2015 |
Jul 17, 2015 |
Printed |
Page 88
validate method of TaskSerializer |
To accommodate the changes for previous errata related to differences between Django REST framework 2.4 and 3.X, another update is needed in the validate method.
status = int(attrs.get('status'))
should be changed to
status = attrs.get('status', Task.STATUS_TODO)
to avoid errors when the status is not given by the client.
|
Mark Lavin |
May 03, 2015 |
Jul 17, 2015 |
Printed |
Page 49
Code block for build.py |
os.makedirs(settings.STATIC_ROOT) should be moved outside of the else block to match the indentation of call_command below it. This prevents any issues of trying to call `build` with a single page before ever calling it to generate all pages.
|
Mark Lavin |
May 03, 2015 |
Jul 17, 2015 |
PDF |
Page 34
Terminal session |
The following command given in Page 34 fails because of a typo.
hostname $ python prototype.py runserver
should be changed to
hostname $ python prototypes.py runserver
The name of the Python file is given as "prototypes.py" in page 33 and also in the examples at
https://github.com/lightweightdjango/examples/tree/chapter-3/static_site_generator
Note from the Author or Editor: This same typo also appears on page 39.
|
A. Yoldas |
Apr 29, 2015 |
Jul 17, 2015 |
PDF |
Page 33
2nd paragraph |
In the line
"Let's add empty js and css folders too, and put them in the templates folder."
the last few words should be
"... put them in the static folder."
This is confirmed by the folder structure displayed in the middle of the page 33.
|
Nagarajan |
Jan 08, 2015 |
Jul 17, 2015 |
PDF |
Page 87
Function validate_end |
I'm using Python 2.7.9 to implement most of development found on this book. I'm getting the following error after implementing the validate_end function:
++++++++++++++++++++++++++++++++
Request Method: POST
Request URL: http://localhost:8000/api/sprints/
Django Version: 1.7.1
Exception Type: TypeError
Exception Value:
validate_end() takes exactly 3 arguments (2 given)
Exception Location: /Users/tiagovieira/.virtualenvs/django-learning/lib/python2.7/site-packages/rest_framework/serializers.py in to_internal_value, line 399
Python Executable: /Users/tiagovieira/.virtualenvs/django-learning/bin/python
Python Version: 2.7.9
+++++++++++++++++++++++++++++++++
When I looked at the Django Rest Framework, it show that the validate function takes only 1 argument (apart from itself).
Not sure if this is caused by the Python version I'm using or if this is a technical error.
Thanks.
Tiago
Note from the Author or Editor: The original code for this section was written for Django Rest Framework version 2.4.X. After publication, version 3.0 was released with incompatible changes for the serializers. If you see this error, to make the code compatible with version 3.0.X you need to change the SprintSerializer.validate_end:
class SprintSerializer(serializers.ModelSerializer):
...
def validate_end(self, value):
new = self.instance is None
changed = self.instance and self.instance.end != value
if (new or changed) and (value < date.today()):
msg = _('End date cannot be in the past.')
raise serializers.ValidationError(msg)
return value
and TaskSerializer.validate_sprint:
class TaskSerializer(serializers.ModelSerializer):
...
def validate_sprint(self, value):
if self.instance and self.instance.pk:
if value != self.instance.sprint:
if self.instance.status == Task.STATUS_DONE:
msg = _('Cannot change the sprint of a completed task.')
raise serializers.ValidationError(msg)
if value and value.end < date.today():
msg = _('Cannot assign tasks to past sprints.')
raise serializers.ValidationError(msg)
else:
if value and value.end < date.today():
msg = _('Cannot add tasks to past sprints.')
raise serializers.ValidationError(msg)
return value
See http://www.django-rest-framework.org/topics/3.0-announcement/#serializers and updates
to the example project https://github.com/lightweightdjango/examples/commit/bbf88e20765ede522cd2026e08e2a24c7da33b89 for more details.
|
Tiago Vieira |
Dec 19, 2014 |
Jul 17, 2015 |
PDF |
Page 72
Chapter 4. Building a REST API (Task and User Endpoints) |
firstly i can confirm dokenzy issue with read_only=True RelationalField error
seondly:
I'm getting error
It is redundant to specify `get_links` on SerializerMethodField 'links' in serializer 'SprintSerializer', because it is the same as the default method name. Remove the `method_name` argument.
in classes
class SprintSerializer(serializers.ModelSerializer):
links = serializers.SerializerMethodField('get_links')
and if i change to this:
class SprintSerializer(serializers.ModelSerializer):
links = serializers.SerializerMethodField()
everything is ok. this also applies to class TaskSerializer and fields status_display, link
Note from the Author or Editor: The original code for this section was written for Django Rest Framework version 2.4.X. After publication, version 3.0 was released with incompatible changes for the serializers. If you see this error, to make the code compatible with version 3.0.X you need to change the SprintSerializer.links, TaskSerializer.status_display, TaskSerializer.links, and UserSerializer.links to remove the provided method name:
class SprintSerializer(serializers.ModelSerializer):
links = serializers.SerializerMethodField()
...
class TaskSerializer(serializers.ModelSerializer):
...
status_display = serializers.SerializerMethodField()
links = serializers.SerializerMethodField()
...
class UserSerializer(serializers.ModelSerializer):
...
links = serializers.SerializerMethodField()
...
See the release notes http://www.django-rest-framework.org/topics/3.0-announcement/#serializer-fields and updates
to the example project https://github.com/lightweightdjango/examples/commit/3abda6f23d60fc0a3ef98d7658861dcb97cce81f for more details.
|
Dade |
Dec 17, 2014 |
Jul 17, 2015 |
PDF |
Page 75
class TaskSerializer :: assigned = serializers.SlugRelatedField() |
Thank you this great book. This book is that I am looking for a long time.
When I am coding Chapter 4, I met a error:
AssertionError at /api/
Relational field must provide a `queryset` argument, or set read_only=`True`.
So, I looked into the rest_framework code and I think I found the reason.
__init__() of the class 'RelatedField' in rest_framework/relations.py has been changed since version 3.0.0:
class RelatedField(Field):
def __init__(self, **kwargs):
self.queryset = kwargs.pop('queryset', None)
assert self.queryset is not None or kwargs.get('read_only', None), (
'Relational field must provide a `queryset` argument, '
'or set read_only=`True`.'
)
I guess your code has to be changed like this:
assigned = serializers.SlugRelatedField(
slug_field=User.USERNAME_FIELD, required=False, read_only=True)
But I am not cetain because I am newbie at Django.
I'm thankful if you check my suggestion.
Best regards
Note from the Author or Editor: The original code for this section was written for Django Rest Framework version 2.4.X. After publication, version 3.0 was released with incompatible changes for the serializers. If you see this error, to make the code compatible with version 3.0.X you need to change the TaskSerializer assigned field to include the queryset argument as instructed by the error message:
assigned = serializers.SlugRelatedField(
slug_field=User.USERNAME_FIELD, required=False,
queryset=User.objects.all())
See the release notes http://www.django-rest-framework.org/topics/3.0-announcement/#serializer-fields and updates
to the example project https://github.com/lightweightdjango/examples/commit/9a2ce32a39a3192ee637700f0007cc1756b7f3ee for more details.
|
dokenzy |
Dec 16, 2014 |
Jul 17, 2015 |
Printed |
Page 155
.tasks selector block in the CSS |
The overflow: scroll; property should be removed from the .tasks selector in the example CSS. When this is included scollbars appear around the tasks block which are unwanted.
|
Mark Lavin |
Dec 01, 2014 |
Jul 17, 2015 |
Other Digital Version |
?
? |
I am reading the Kindle version of the book, so I don't have the original page numbers. In project 2, the image placeholder service, there is a small error in the template for the home page. The example URL in the body text directs the user to use /placeholder/<width>x<height> to get a placeholder image, the the url_conf for the project actually uses /image/<width>x<height> to obtain a placeholder image.
Note from the Author or Editor: The example URL in the template is incorrect. /placeholder/<width>x<height>/ should be /image/<width>x<height>/ in the HTML.
|
Tony Morrow |
Nov 22, 2014 |
Jul 17, 2015 |
|
6
Ch 6 Add Task View |
Experienced a name collision on the "add" class for Sprints and Tasks, so clicking the Add Task button resulted in BOTH the new-sprint-template and new-task-template being displayed.
Problem resolved with unique name of "addSprint"
<button class="addSprint" type="submit">Add Sprint</button>
in index.html and
events: {
'click button.addSprint': 'renderAddForm'
},
in HomepageView of views.js
Note from the Author or Editor: A call to undelegate the view events is missing from two of the AppRouter.render method snippets in Chapter 5. this.current.undelegateEvents(); should be called just prior to this.current.$el = $(); The AppRouter.render method is shown three times in the chapter and this call is missing from the first and the last time it is shown.
|
John Graves |
Nov 17, 2014 |
Jul 17, 2015 |