Python Flask Tutorial: Full-Featured Web App Part 3 - Forms and User Input

Corey Schafer · 801K views · 2018 · 48:16

Open on YouTube

Web developmentPython, Ruby & scripting languagestutorial

Why Stack Overflow recommends it

Stack Overflow users link it when answering or debugging Flask form handling, validation and flash message questions.

Recommended by 2 people across 2 different months, 2019 to 2024.

What it is

Part 3 of Corey Schafer's Flask blog series, a hands-on tutorial on building forms with Flask-WTF, validating user input, and showing flash messages when input is invalid. It follows along with a registration and login form for a full-featured blog app.

What people said

Recommends Carlos · 2020-04 · Stack Overflow · on “How to add a value to a database in Flask without using a form?”

There is no need for you to write the HTTP request in JavaScript. Check out Flask-WTF [LINK] , a package that handles forms in Flask. You will be using it often when developing in Flask. This tutorial [this video] explains how to use it very well.

Recommends vgenovpy · 2024-01 · Stack Overflow · on “How to validate in Flask Forms under certain conditions?”

Maybe I'm getting something wrong, but let me get this forward The user set license_type to PRO and is not giving values for po & cpe count and because this information is not enough, you'd like to give some kind of message like: 'Please set po, cpe count values' If that's the case, flask offers flash , which is a message that it will be displayed if the user bad use the form, is really straight forward. docs: [LINK] video explaining: [this video] starting at timestamp 25:10 If this doesn't reply completely to your question, I'm pretty sure that you'll get your answer in the video attached above, also regarding data validation. Kind regards!

Cites Eric · 2019-12 · Stack Overflow · on “Flash message not displaying in flask”

I am following this [this video] flask tutorial on youtube, the user doesn't get re-directed to the homepage after signing up and there's no flash message being displayed. My python version is 3.6.4 @app.route("/register", methods=['GET', 'POST']) def register(): form = RegistrationForm() if form.validate_on_submit(): flash(f'Account created for {form.username.data}!', 'success') return redirect(url_for('home')) return render_template('register.html', title='Register', form=form) In my layout.html, this is a bootstrap template. <main role="main" class="container"> <div class="row"> <div class="col-md-8"> {% with messages = get_flashed_messages(with_categories=true) %} {% if messages %} {% for cat