Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
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 upRelated 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