Does anyone know about python flask and wtf forms?....

In summary, The code initializes a Flask application and imports a RegistrationForm from the file. It then sets up a route for the registration page and renders a template for the register.html page with the registration form. The RegistrationForm class defines fields for username, email, and password, and includes validators for character length and password matching. The HTML form in register.html uses these fields and displays them with labels and input fields. The CSS can be modified to change the formatting of the form. It is recommended to use either break tags or tables to organize the form. Additionally, the use of InputRequired() or DataRequired() validators may depend on individual needs and preferences.
  • #1
TL;DR Summary
I am trying to space the forms in the registration route but it is not working.
from flask import Flask, render_template
from forms import RegistrationForm

@app.route("/register", methods = ['POST', 'GET'])
def register():
    forms = RegistrationForm()
    return render_template('register.html',form=forms)
from wtforms import Form, BooleanField, StringField, PasswordField, validators
# what does Form do
class RegistrationForm(Form):
    username = StringField('Username', [validators.Length(min=2, max=25)])
    email = StringField('Email', [validators.Length(min=4, max=25)])
    password = PasswordField('New Password', [
    validators.EqualTo('confirm', message='Passwords must match')
    confirm_password = PasswordField('Repeat Password')

    display: block;
<!DOCTYPE html>
        <title> register </title>
        <link rel="stylesheet" type="text/css" href="register.css"/>
        <form action="/register" id="register_forms"  method="POST">
       fields/16379203 -->       
            <label for="username">
            <label for="email">
            <label for="password"> 
            <label for="password_form">
                Confirm Password
                <input type = "button"  Submit value = "Submit" >

Here is the output I am trying to change.

Technology news on
  • #2
You can use break tags between each label to put it on a separate line Or you can use tables to organize the form in a row column format.

Basically, it’s the html, css files you need to change To get the format you want.
  • #3
Last edited:

What is Python Flask?

Python Flask is a popular web framework for building web applications in the Python programming language. It is known for its simplicity, flexibility, and ease of use.

What is WTF Forms?

WTF Forms is an extension of Python Flask that simplifies the process of creating and validating web forms. It provides reusable form components and built-in validators to ensure data is entered correctly.

How do I install Python Flask and WTF Forms?

To install Python Flask and WTF Forms, you will need to have Python installed on your computer. Then, you can use a package manager like pip to install both Flask and WTForms. Detailed installation instructions can be found on their respective websites.

What are the benefits of using Python Flask and WTF Forms?

Python Flask and WTF Forms offer a variety of benefits, including a simple and intuitive syntax, built-in support for unit testing, and a large community of developers for support and resources. They also allow for easy integration with other Python libraries and databases.

Are there any limitations to using Python Flask and WTF Forms?

While Python Flask and WTF Forms offer many advantages, they may not be the best choice for all web applications. They may not be suitable for large and complex projects, and may require additional extensions for certain features. It is important to assess the needs of your project before deciding on a web framework.

Similar threads

  • Programming and Computer Science
  • Programming and Computer Science
  • Programming and Computer Science