Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
- Before and After Requests 4:27
- To the ends of the request 3 objectives
- LoginManager 4:38
- Set up LoginManager 4 objectives
- Flask-WTF Forms 9:39
- Form with Validators 4 objectives
- Registration View 6:33
- Macros 4:19
- Login View 6:17
- Form View 3 objectives
- Logout View 3:24
- Controlling sessions 2 objectives

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
We don't want to have to type out all of the template code required to render forms every single time we render a form. Let's make a Jinja2 macro, or a template function, that'll handle this work for us.
New terms
-
{% macro %}
- A function in a template to repeat code on demand. Often really useful for things like form fields.
Note
If you're constantly getting a locked database, change your User.create_user
method to the following:
@classmethod
def create_user(cls, username, email, password, admin=False):
try:
with DATABASE.transaction():
cls.create(
username=username,
email=email,
password=generate_password_hash(password),
is_admin=admin)
except IntegrityError:
raise ValueError("User already exists")
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up-
David Sampimon
12,026 Points1 Answer
-
Chase Svoboda
Python Development Techdegree Graduate 8,466 Points2 Answers
-
Callum Anderson
Data Analysis Techdegree Student 10,200 Points1 Answer
-
justin behringer
Python Development Techdegree Student 6,245 Points1 Answer
View all discussions for this video
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up