The Flask wtforms subclass uses constructors to keep reporting errors and asking for help.

when writing web programs using the Flask web framework, the form class selects flask_wtf.
inherits FlaskForm when creating a class, and writes constructs in subclasses that always report errors. I don"t know why?

from flask_wtf import FlaskForm

class Auth(FlaskForm):
    
    def __init__(self, *args, **kwargs):
        super(Auth, self).__init__(*args, **kwargs)


"""  """
from . import forms

@auth.route("/")
def index():
    s = forms.Auth()
    return render_template("auth/index.html")

clipboard.png

Apr.15,2021

the object must be created in advance in the class property and the value of the property must be set in the constructor.

from flask_wtf import FlaskForm
class Auth(FlaskForm):
 
    selects = SelectField('selects')
    
    def __init__(self):
        super(Auth, self).__init__()
        self.selects.choices = [('value', 'text'), ('value', 'text')]

my project https://github.com/eastossifr. uses flask-wtf,. I suggest you have a look when you are free. I am often online. If you don't understand, you can ask me directly.

Menu