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

AI Thread Summary
The discussion focuses on creating a registration form using Flask and WTForms. The provided code outlines a Flask route for rendering a registration template that includes fields for username, email, password, and password confirmation. The RegistrationForm class defines these fields with specific validators for length and password matching. There are inquiries about modifying the HTML and CSS for better layout, suggesting the use of break tags or tables for organization. Additionally, there is a question regarding the necessity of using InputRequired() or DataRequired() validators, given that minimum and maximum character limits are already set. The CSS issues are also highlighted, indicating that the styling may not be applied correctly.
gtguhoij
Messages
33
Reaction score
2
TL;DR Summary
I am trying to space the forms in the registration route but it is not working.
[CODE lang="python" title="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)[/CODE]

[CODE lang="python" title="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')[/CODE]

[CODE title="register.css"]
label
{
display: block;
}
[/CODE]
[CODE lang="html" title="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>[/CODE]

Here is the output I am trying to change.

 
Technology news on Phys.org
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.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
hi; i purchased 3 of these, AZDelivery 3 x AZ-MEGA2560-Board Bundle with Prototype Shield and each is reporting the error message below. I have triple checked every aspect of the set up and all seems in order, cable devices port, board reburn bootloader et al . I have substituted an arduino uno and it works fine; could you help please Thanks Martyn 'avrdude: ser_open(): can't set com-state for "\\.\COM3"avrdude: ser_drain(): read error: The handle is invalid.avrdude: ser_send(): write...

Similar threads

Replies
9
Views
2K
Replies
2
Views
1K
Back
Top