2014-09-28T01:32:37Z
The Flask Mega-Tutorial: Now with Python 3 Support
After more than a year working on various projects on the side of my day job, I have now found some time to rest and return to the blog, which I haven't cared for much during this time.
The number one problem I see from my readers is issues when trying to follow my Flask Mega-Tutorial using current versions of Flask, its extensions, or Python 3. In this article I quickly describe the updates I have made to the tutorial.
Announcing the Updated Flask Mega-Tutorial
I'm happy to announce that I have revised all the articles that are part of this tutorial, along with the tutorial's code repository on GitHub. The example code now works with Flask 0.10.1, and all the dependencies were also upgraded to current versions. The example application is now compatible with Python 2.7 and Python 3.3+, and I have also made several changes towards PEP8 compliance, something I did not pay too much attention two years ago when I wrote the original articles.
Migrating microblog
to Python 3 required mostly simple syntax updates, but there were a couple of areas that proved tough:
- Flask-Babel has problems when used with Flask 0.10 and newer. This is related to a change in how Flask serializes the user session in this version. I have blogged about this separately, since this is likely affecting many projects unrelated to this tutorial.
- While testing full text search I have found an issue with the Whoosh package under Python 3. There is a bug report for this problem, but there is no fix yet. I have left support for full text search disabled in Python 3. I will enable it once Whoosh works well with that version.
As far as the content of the tutorials, I decided to stay true to the original articles and not introduce any major changes. That means that for those that are familiar with the tutorial there isn't any significant changes, other than the code will now work with current versions of Python and all the packages. Related to this I think it is important to note the following:
- The Database article shows how to track migrations using package sqlalchemy-migrate. Today a lot of people use Alembic instead, many through my own Flask-Migrate extension. I have covered the use of Flask-Migrate and Alembic well in my other tutorials, so I decided to stay with sqlalchemy-migrate for this one. Note that I have updated the version of sqlalchemy-migrate to the current version.
- When I wrote the Facelift article the current version of Twitter Bootstrap was 2.3.2. I have not updated the templates to work with current 3.x releases, since that is largely unrelated to the main goal of the tutorial.
- Two years ago when I started writing this tutorial the use of blueprints with Flask was new, I did not cover blueprints at all. The training material I did with O'Reilly and my PyCon presentations all have very good coverage of blueprints, so I strongly recommend that you use those to learn about this topic.
In case you have no idea what the topics in this tutorial are, here is the complete list of 18 articles, with links to them:
- Part I: Hello, World!
- Part II: Templates
- Part III: Web Forms
- Part IV: Database
- Part V: User Logins
- Part VI: Profile Page And Avatars
- Part VII: Unit Testing
- Part VIII: Followers, Contacts And Friends
- Part IX: Pagination
- Part X: Full Text Search
- Part XI: Email Support
- Part XII: Facelift
- Part XIII: Dates and Times
- Part XIV: I18n and L10n
- Part XV: Ajax
- Part XVI: Debugging, Testing and Profiling
- Part XVII: Deployment on Linux (even on the Raspberry Pi!)
- Part XVIII: Deployment on the Heroku Cloud
Recommended Flask Learning Path
I have been very prolific and created several tutorials since I completed the Mega-Tutorial. In this section I want to summarize what I have created and sort it by experience level to help you decide where to start.
Introductory Level
- An Introduction To Flask (4.5 hour long video tutorial, paid)
- Flask Workshop (3 hour long PyCon presentation, free)
- Flask Mega-Tutorial (18 part blog series, free)
Intermediate Level
- Flask Web Development (book, paid)
- Flask by Example (3.5 hour long PyCon presentation, free)
- REST API articles (4 part blog series, free)
Advanced Level
- Writing RESTful Web Services with Flask (45 minute long PyCon presentation, free)
- Building Web APIs with Flask (3.5 hour video tutorial, paid)
- Flask at Scale (3 hour long PyCon presentation, free)
What's Next
In the near future (and until I find a next major project to absorb all my free time) I plan to return to blogging. I have several ideas for new Flask articles, many for topics I originally intended to include in my book, but then had to remove to keep the book from getting larger than originally planned (even though in the end the book ended up having about 100 more pages than the target page count!). Examples of what you can expect to see here in the following weeks:
- Creating administration interfaces
- Implementing CORS in Flask APIs
- Infinite scrolling
- Single page applications with Flask on the backend
I also expect to write a fair amount of articles related to cloud computing and in particular OpenStack, which is my current focus at work.
Miguel
#1 Andy said 2014-09-29T09:49:46Z
#2 Jon said 2014-09-30T11:14:20Z
#3 Paul said 2014-10-01T17:44:14Z
#4 Mohamed Ali AbElslam said 2014-10-10T00:17:03Z
#5 B. A said 2014-10-17T17:57:28Z
#6 TheChuckMo said 2014-10-25T19:25:00Z
#7 Marina said 2014-11-07T12:17:56Z
#8 Miguel Grinberg said 2014-11-07T20:14:27Z
#9 Daniel said 2014-11-14T12:25:16Z
#10 Nicholas said 2014-12-24T15:57:39Z
#11 leasunhy said 2015-02-04T15:02:44Z
#12 Brijesh said 2015-02-21T15:58:31Z
#13 VD said 2015-06-28T20:12:33Z
#14 Miguel Grinberg said 2015-07-01T18:07:32Z
#15 Dave said 2015-07-28T18:24:45Z
#16 Miguel Grinberg said 2015-08-02T05:44:24Z
#17 1q84 said 2015-08-07T14:15:58Z
#18 Miguel Grinberg said 2015-08-07T16:24:32Z
#19 Alex said 2015-09-16T08:14:16Z
#20 Dattatreya Mohapatra said 2015-10-20T22:08:22Z
#21 Miguel Grinberg said 2015-10-22T05:17:24Z
#22 Condit said 2016-12-20T18:47:34Z
#23 Miguel Grinberg said 2016-12-20T21:55:49Z