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

  • #1
gtguhoij
33
2
TL;DR Summary
I am trying to space the forms in the registration route but it is not working.
flaskblog.py:
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)




forms.py:
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.DataRequired(),
    validators.EqualTo('confirm', message='Passwords must match')
    ])
 
    confirm_password = PasswordField('Repeat Password')

register.css:
label
{
    display: block;
}



register.html:
<!DOCTYPE html>
<html>
    <head>
        <title> register </title>
        <link rel="stylesheet" type="text/css" href="register.css"/>
    </head> 
    <body> 
        <form action="/register" id="register_forms"  method="POST">
       fields/16379203 -->       
            <label for="username">
                Username   
               {{(form.username)}}
            </label>
            
            <label for="email">
                Email
                {{form.email}}
            </label>
 
            <label for="password"> 
                Password
                {{form.password}}
            </label>
            
            <label for="password_form">
                Confirm Password
                {{form.confirm_password}}
            </label>
            
            <label>
                <input type = "button"  Submit value = "Submit" >
            </label>   
        </form>
    </body>     
</html>

Here is the output I am trying to change.

 

Answers and Replies

  • #2
14,194
8,181
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
gtguhoij
33
2
Last edited:

Suggested for: Does anyone know about python flask and wtf forms?....

  • Last Post
Replies
24
Views
823
  • Last Post
Replies
9
Views
738
  • Last Post
Replies
2
Views
564
Replies
13
Views
1K
  • Last Post
6
Replies
187
Views
6K
  • Last Post
Replies
2
Views
364
Replies
0
Views
386
  • Last Post
Replies
10
Views
490
  • Last Post
Replies
15
Views
754
  • Last Post
Replies
7
Views
439
Top