Posted byon under
Today I'm super-excited to share that I have made available a major update to the Flask Mega-Tutorial, which I'm calling the "2024 Edition".
In the following sections I'll re-introduce the tutorial in case you have not seen it before, and I'll also go over the changes and improvements in this revised edition.
What is the Flask Mega-Tutorial?
Back in 2012, I decided to start this software development blog. Because I am a do-it-yourselfer at heart, instead of using Blogger or WordPress, I sat down and wrote my own blog engine, using a then little known web framework called Flask. I knew I wanted to code it in Python, and I first tried Django, which was the most popular Python web framework at the time. But unfortunately Django seemed too big and too structured for my needs. I've found that Flask gave me as much power, while being small, unopinionated and unobtrusive.
Writing my own blog engine was an awesome experience that left me with a lot of ideas for topics I wanted to blog about. Instead of writing individual articles about all these topics, I decided to write a long, overarching tutorial that Python beginners can use to learn web development. And just like that, the Flask Mega-Tutorial was born!
The tutorial has been through a number of revisions:
- 2012: The original blog series was published.
- 2018: A major revision backed by a Kickstarter project. The updated tutorial was re-published on this blog, and also released in book and video formats.
- 2021: A minor revision of the written content from 2018, to coincide with the release of Flask 2.0.
- 2024: A new, larger revision of the written content to cover the releases of Flask 3.0 and SQLAlchemy 2.0 (Yes, technically I'm releasing this update a month before 2024, in December 2023).
From day one I have made a commitment to offer this tutorial for free on this blog, and that remains the case with this update. If you'd like to support my work, consider buying the book version of this or any of my other books.
NOTE: I have submitted the 2024 Edition of the book to Amazon, but it may take a few days or maybe a week or two for the new versions to be shown. If you are interested in buying the book, please be sure that you are buying the new edition, with "2024 Edition" written on the cover.
What Are The Changes In The 2024 Edition?
If you are familiar with the 2018/2021 content, in this section I highlight the changes and improvements I have made for the 2024 edition.
The entire project has been updated to use the Flask 3.0.0 release, which is the latest at the time I'm writing this. I have also made sure that the project is 100% compatible with the 2.3.x releases, which a lot of people still use.
Along with support for Flask 3, I have upgraded all extensions and dependencies to their latest available versions.
Moving to SQLAlchemy 2 was the largest change of all, as SQLAlchemy have introduced a number of improvements in their latest 2.x releases that I wanted to take advantage of. In particular, with the updated tutorial you will learn how to:
- Define database models using a modern syntax based on type hints that plays nice with code analyzers and IDEs
- Use the new, more powerful query interfaces based on the
- Replace the legacy "dynamic" relationships with the now recommended "write-only" ones.
The use of Bootstrap 3 was one of the parts of the tutorial that made me the least proud, but due to the lack of good support for newer releases of Bootstrap in the Flask ecosystem I put off upgrading for a long time.
Now I have made the jump to the 5.3.2 version, latest at the time I'm writing this. For this update I'm showing you how to incorporate Bootstrap into the application using support from Jinja features such as macros, without the use of any third-party Python package.
Support For Python 3.8 to 3.12
I also wanted to make sure that you have a good experience regardless of the Python version that you use. My decision was to support all the versions between 3.8 and 3.12.
Having support for this wide range of versions required two changes to the tutorial with respect to the previous edition:
- To test email delivery, I showed you how to use the
DebuggingServerclass of the
smtpdmodule. Unfortunately the
smtpdmodule was deprecated long ago (before Python 3.8) and it was actually removed in Python 3.12. I am now using the
aiosmtpdthird-party package for this.
datetime.utcnow()function was my favorite for getting the current time in UTC units. This function was deprecated in Python 3.12 and produces an annoying warning when it is used in that version of Python (I had a thing or two to say about this deprecation, if you are interested). In the 2024 edition, I'm using aware timestamps with explicit UTC timezone, following the recommendation from Python maintainers.
In addition to deprecations, the tutorial still had some remnants of the old days when I supported Python 2. For example, classes were still created with
object as parent class, and
super() included arguments. All these legacy patterns have now been removed.
No More jQuery
For a long time, jQuery was a must-have library for any web page. Trying to do anything in the front end without jQuery was painful, as each browser had its own quirks and behaviors that needed to be considered.
But consistency in browser APIs has improved greatly in recent years, so much that jQuery is now seen as unnecessary. For example, Bootstrap releases up to and including version 4 all required jQuery as a dependency, but Bootstrap 5 did away with it, and for that reason I have also eliminated all uses of jQuery in this tutorial, replacing them with native browser APIs.
What Has Not Changed With This Update?
The main aspect of the tutorial that has not changed is the chapter layout. There are still 23 chapters, and they are the same as in the 2018 and 2021 revisions.
I thought about replacing the Heroku chapter, which now requires a paid account, but decided against it, simply because I know a lot of people who even today are happy Heroku customers and were introduced to the platform through this tutorial (I should make the clarification that I do not make any money from sending people to Heroku and never had). Those who consider a paid Heroku account a deal breaker can skip that chapter.
Lastly, I'm sure this is going to disappoint some people, but I have decided to not create new versions of the video course for the 2024 edition. Unfortunately with this round of updates I would have to re-record the entire tutorial, as every single chapter has received significant updates (especially those related to the use of SQLAlchemy 2).
The sad reality is that I'm not selling a lot of video courses, as most people in my audience appear to prefer paper books and ebooks. So at this point the effort and time investment that is required to create an updated video course is hard to justify.
I'm open to reconsider this in the future, but my current plan is to continue selling the 2018/2021 edition of the video course for those interested, both on my own platform and also on Udemy. I have added a note to indicate that the tutorial is slightly out of date and that you may need to work alongside the written tutorial on this blog (which is available free of charge to anyone) if you want to learn what the updates are.
Keep The Feedback Coming!
To me it is really amazing that the Flask Mega-Tutorial is almost 12 years old, and that even after all these years I continue to receive comments, questions and feedback from people learning with it. I appreciate all the support that I have received over the years. This gives me the motivation to continue making updates to it, so keep 'em coming!
Are you ready to begin your web development journey with Flask? Click here to start!
Become a Patron!
Hello, and thank you for visiting my blog! If you enjoyed this article, please consider supporting my work on this blog on Patreon!