Announcing the Flask Mega-Tutorial, 2024 Edition

Posted by
on 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".

Flask Mega-Tutorial

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.

Flask 3.0

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.

SQLAlchemy 2.0

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 select() function
  • Replace the legacy "dynamic" relationships with the now recommended "write-only" ones.

Bootstrap 5.3

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 DebuggingServer class of the smtpd module. Unfortunately the smtpd module was deprecated long ago (before Python 3.8) and it was actually removed in Python 3.12. I am now using the aiosmtpd third-party package for this.
  • The 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!

24 comments
  • #1 Biswajit Kaushik said

    Miguel, you are a boon to Flask community. Thanks always for such great content.

  • #2 Ciro said

    Hi Miguel
    Thanks for all the effort you put in pushing forward the Flask Community.

    I want to buy the digital version of the 2024 edition on Amazon. But I was wondering whether this is a must to have Amazon's Kindle to be able to read the book. Can I read it no matter what digital book reader I may use?

    Regards from Argentina

  • #3 Miguel Grinberg said

    @Ciro: You have to use a Kindle reader to read the book. This can be an actual Kindle device, a Kindle app for iOS or Android, or the Kindle web application.

  • #4 Corey said

    Will you be allowing comments on the new articles?

  • #5 πŸŒ™ said

    I would first like to extend my appreciation for your work, your writing style and your attention to detail and best practices.

    Will you still be responding to new comments that are left on the 2018 version of the tutorial or should all new comments be left on the corresponding pages of the new version?

    I also have a suggestion for a general feature of this blog which I did not find available, namely a search feature that one can use to search the entire blog. I was looking for a particular comment I remember seeing and I wanted to see your response but unfortunately I think the only way I can find it is to scroll through many pages of comments on different chapters of the tutorial.

    Also, when leaving a comment on your blog, the form requires an email address but I never receive an email when someone (you) reply to the comment. Instead I have to remember to keep checking the page for a reply.

    Also, if you care to share, how did you master Flask on your own, back when it was still in its infancy? Did you comb through the documentation and try everything out? I am looking for a general method to use when learning about a new tool or framework without having to necessarily rely on tutorials. I know the documentation is (theoretically) supposed to tell you everything there is to know, but in reality too often there is information missing or it is poorly or confusingly communicated.

  • #6 πŸŒ™ said

    I noticed that on the new Flask tutorial there is no option to leave comments. Is this intentional?

    Also, I noticed a few typos in the new tutorial, some of which were probably overlooked when you were redoing the tutorial. What (if any) is the preferred way to get them fixed?

    Lastly, why is there no option for people to be able to edit their comments on these blog posts?

  • #7 Brian said

    I got the kindle edition on Amazon, but when I open it the title page still says it is the "2022-04-26" edition. Was that page changed in the new edition and if so, is Amazon not distributing the new edition despite the new cover being displayed?
    Thanks.

  • #8 Kevin Mutwiri Mwenda said

    Thank you so much Miguel

  • #9 Shahrukh said

    Quick tip: For anyone that has the old version of the book on Kindle app, they need to do "Remove download" and then tap on the book icon again because even if the cover shows as 2024, it will (at least in my case) loaded the old version from 2018. It wasn't until I did "Remove download" that I saw the new content load. This was as of yesterday 12/3/2023.

  • #10 Miguel Grinberg said

    @Corey: of course! Comments are allowed on all the articles.

  • #11 Miguel Grinberg said

    @πŸŒ™: I'm not sure what happened with the comments, I do see the option to enter comments from here. Could have been a deployment hiccup, but it appears resolved now. If you find typos, feel free to leave a comment on the corresponding chapter and I'll address them. Thanks!

    To search on this site you can add site:miguelgrinberg.com on Google. That will return results only from this site.

    how did you master Flask on your own

    I read the source code.

  • #12 Miguel Grinberg said

    @Brian: I don't think Amazon updates books that were purchased in the past. You will continue to see the version of the book that you ordered, not the current version.

  • #13 Miguel Grinberg said

    @Shahrukh: Good to know. I wasn't aware you could do that.

  • #14 Daedox said

    Thx Miguel that's awesome!
    Udemy and so on is nice but I guess YT is the first address for the most people if they are looking for tutorials.

  • #15 Dan said

    Just a quick thanks for your dedication and for updating the Flask Mega-Tutorial so quickly after the breaking changes!

  • #16 Michal said

    Thank you for all your efforts and I am excited about this update! However, I am not able to buy the book on the Amazon, it says: "This title is not currently available for purchase". Is the book not released yet ? Or are there any country restrictions (I am trying to buy the Kindle version so this would not make much sense to me)?

  • #17 Miguel Grinberg said

    @Michal: I'm not sure. The ebook has been available for sale for more than a week now. I suggest you try again and see if it will eventually let you purchase it, because it is definitely available.

  • #18 Bill said

    Hi Michael,

    Last year I picked up your OReilley book (2nd ed Flask Web Development) but have not jumped into it yet. Planning to devote some time this month, but I'm wondering, if time is somewhat constrained, do you think I would be better served working through the book or working through this updated tutorial? I saw a few discussions on reddit regarding the book vs older versions of the tutorial, but maybe those have become dated? Thanks.

  • #19 Miguel Grinberg said

    @Bill: the O'Reilly book is from 2018. In reality not a lot of things have changed in Flask since then, so a lot of that book remains up to date, but some things you will need to refresh.

  • #20 julian said

    Miguel,

    I have the previous one and I am buying this in ebook just to support your work. Thanks for the effort put into this.

    Cheers.

    JC

  • #21 David said

    Hi Miguel. Just curious if you will be updating the e-book downloads for the video course? I certainly understand not updating the videos.

    Cheers,

    David

  • #22 Miguel Grinberg said

    @David: No, because the video and the written content need to match so that you can use them together. If/when I decide to make a video course based on the new edition both will be updated together.

  • #23 Alan Williams said

    Hi Miguel,
    Thanks for all of this. Do you have plans to update the Udemy course? Is the old one still worth following?
    Thank you

  • #24 Miguel Grinberg said

    @Alan: As I said in the article, I currently have no plans to update the video course. A lot of the video content is still applicable, so yes, it does have value.

Leave a Comment