If the form data is valid, we need to save it in the users table.
- [Instructor] Now that we've handled the case…where there's incorrect data submitted,…in this video, let's handle the case…where correct data is submitted.…So far we're using a temporary placeholder string…that says success when all the fields exist.…Let's replace it with real code.…When a form has all valid data and is submitted,…we want to save that data into the database.…To do this, let's add the following code to (mumbles).…First import the user class from models.py.…Then create a new useful instance of the user object,…and initialize it with data from the sign up form.…
So initialize it here.…And for each field of the form,…you can touch the data that was submitted…by using the .data attribute.…And then insert the new user object…into the users table, and save it.…You can do this using DB session add,…and DB session commit.…And that's it.…Now when we enter valid data in the sign up form,…a new record should get saved to the database.…So fill out the sign up form, click sign up,…and you should see success, indicating that the form…
The need for talented developers is greater than ever before. A basic grounding in a framework as simple, powerful, and easy-to-learn as Flask—a Python micro framework—can help launch your programming career. Get a basic grounding in the fundamental concepts of web development, as well as the hands-on experience required to successfully build web apps with Flask, in this course with Packt trainer Lalith Polepeddi.
It starts with turning your computer into a modern development machine. Then learn everything you need to know about Flask: models, views, controllers, web templates, forms, validation, and API interactions. Lalith shows how to apply these concepts and develop a powerful database-backed Flask app, including a full authentication system. Finally, Lalith shows how to extend the app's functionality by integrating it with third-party APIs. When you finish this course, you will be fully equipped to build your very own custom web apps with Flash.
- Setting up your development environment
- Creating a homepage
- Building templates
- Routing with Flask
- Deploying to Heroku
- Storing data
- Creating and rendering forms
- Validating form data
- Creating a user authentication system for login and logout
- Implementing location-based app features
Skill Level Beginner
1. Setting Up the Environment
2. Getting Started
3. Storing Data
4. Signing Up
5. Logging In and Logging Out
6. Authorization and User Roles
7. Bookmarking Places
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.