Errata

Flask Web Development

Errata for Flask Web Development

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
chapter 14

I do not see a version number

"Note how the package used for the API includes a version number in its name."

Liu Haibin  Nov 28, 2018 
Other Digital Version Chapter 14, Example 7-3
Kindle version so can't state.

In the code for __init__.py (Example 7-3) you have: `from config import config` however config.py is, according to Example 7-1, one level up in the folder hierarchy of the basic multiple-file Flask application structure. So this line needs to be `from ..config import config`.



Keith  Dec 05, 2023 
18
"Finding Flask Extensions", final paragraph

Mention is made of an "official Flask Extension Registry", with "Flask Extension Registry" linking to a bitly address. That URL redirects to the "Extensions" page of the Flask documentation, which is good, except that nowhere on that page (currently for newly released v2.1.0) is there any mention whatsoever of such a registry existing.

I had to go back to the "Extensions" page for v0.12.x (now nearly four years and many intervening versions ancient) to find any mention of a registry... in terms of a link that then also redirected to the current "Extensions" page. All of this to say, I don't think the registry has been a thing in years, so it'd probably be a good idea to remove mention of it to minimize confusion.

(Speaking of confusion, feel free to recategorize the type of error this represents; it seemed more important than just a "question," but none of the other error types felt entirely correct either, so I just took a guess.)

Christopher Pinard  Mar 29, 2022 
Other Digital Version 19
2nd paragraph

Hi Support,

I am using the Flask Web Development 2nd Edition Kindle book.
I was able to do:
$ mkdir flasky
$ cd flasky
I am unable to start working on the book because on page 19:

It said to:
$ python3 -m venv virtual-environment-name

However, I am getting the following error message:
The virtual environment was not created successfully because ensurepip is not
available. On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.

apt-get install python3-venv

You may need to use sudo with that command. After installing the python3-venv
package, recreate your virtual environment.

Failing command: ['/home/michaelbox/virtual-environment-name/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']


Please help me so that I can start to work on the examples

Thank you,
Michael

Michael Zdorovyak  Feb 02, 2021 
PDF Page 46
11th paragraph

Hello. I am the reader of Flask Web Development: Developing Web Applications with Python, your code in chapter 3, for example 3b, has no script execution statement.
May I ask, is it missing such code, or what is the consideration?

simon.wang  Sep 14, 2022 
PDF Page 51
1st paragraph and figure 4-3 (Web form after failed validator)

page 51, Figure 4-3. Web form after failed validator

The message "Please fill out this field" is generated on the client side by the web browser in order to force the end-user to fill out the field. This is due to the HTML 5 required attribute that is applied in the input text field.
If you F12 and look at the Network tab you will notice that the form will not be submitted when you click the button and the input text field is empty.
If you tamper the server response to remove the "required" attribute and try to re-submit, a "help-block" p tag is added in the page with the message "This field is required". This is the one that is generated by the field validator on the server side.

Anonymous  Oct 02, 2020 
Printed Page 80
In the "General Note" Blue Crow section

When instructuing how to connect your app to a GMail account the book states:

- Locate the " Allow less secure apps" setting and make sure it is enabled. -

I understand that Google have subsequently disabled this feature. Could you please advise how this can now be achived

Many thanks

David Wheatley  Dec 17, 2020 
Printed Page 95
3rd paragraph

filename is missing underscores:

tests/init.py should be tests/__init__.py

Anonymous  Nov 29, 2020 
PDF Page 152-153
Example 11-3, Example 11-4

Example 11-3 and 11-4 both contain the code current_user.can(Permission.WRITE_ARTICLES). However, the Permission constant is named WRITE (not WRITE_ARTICLES).

Jeanette Samuelsen  Jul 21, 2019 
Printed Page 161
Example 11-11

The example does not show the start of the if block. After

{% include '_posts.html' %}

there should be

{% if pagination %}

like exists in the book's git repo.

Anonymous  Dec 05, 2020 
Printed Page 162
Example 11-13

In the PostForm class, the validator should be DataRequired(), not Required().

Anonymous  Dec 05, 2020 
Printed Page 162
example 11-12

When you paste in the 11e app/__init__.py, you get an ImportError, possibly because the author doesn't install pagedown.

Mike Sweeney  Dec 18, 2021 
ePub Page 190
Example 13-10

Both methods, `moderate_enable` and `moderate_disable`, include the `db.session.add(comment)` lines to change the disabled flag, but they do not include the subsequent `db.session.commit()` statements, preventing the db from being updated correctly.
The statements are in the github repo.

Anonymous  Oct 04, 2021 
ePub Page 192
Chapter 14

The API section is very disjointed and needs a number of changes.

1) All of the uses of `url_for()` need to include the `_external=True` parameter added. Otherwise, all the JSON replies will have relative URLs which would be irrelevant. This includes all the `to_json()` methods as well as the pagination links.

2) The routes should not end in a slash, otherwise it requires the API to always include an ending slash to prevent redirects.

For example, `@api.route('/posts/')`

Using `/api/v1/posts/` works but `/api/v1/posts` replies with an HTML redirect message generated by Flask.

But you used `@api.route('/posts')`

`/api/v1/posts` works as expected and `/api/v1/posts` replies with an API-safe JSON message as it is expecting an id after the slash

3) Checking for mimetypes during error handling no longer seems to work . Tried in both MacOS Terminal and PyCharm Terminal to reach `/api/v1/foo` and I always received an HTML error back.

I did find that checking `'/api/' in request.path` instead gave better results.

Scott McC  Oct 05, 2021 
ePub Page 200
Example 14-4

The Example 14-4 header states that it is changing `/app/api/errors.py`. However, it is actually updating `/app/main/errors.py`

Anonymous  Oct 04, 2021 
ePub Page 225
Example 15-7; and the following description

In your description of the setup code, you state:
"While using app.run() to start a server is now replaced with the flask run command, the app.run() method continues to be supported, and here you can see how it can still be useful for complex unit testing situations."

However, when running the test, I see the following message:
```/.pyenv/versions/3.8.6/lib/python3.8/threading.py:870: Warning: Silently ignoring app.run() because the application is run from the flask command line executable. Consider putting app.run() behind an if __name__ == "__main__" guard to silence this warning.```

Watching Chrome, you can see that the app does not start up, so the test falls apart.

Anonymous  Nov 03, 2021