vendredi 11 juin 2021

How can I make Python if statement, distinguish beetween html elements

I'm making a web application using Python Flask. I have two Flask-WTF to edit my components on a page:

class WorkEDForm(FlaskForm):
    date = StringField("Date", validators=[DataRequired()])
    name = StringField("Name", validators=[DataRequired()])
    details = StringField("Details", validators=[DataRequired()])


class PersonalForm(FlaskForm):
    name = StringField("Name", validators=[DataRequired()])
    details = StringField("Details", validators=[DataRequired()])

And this is a part from my html code which corelates with these form:

    

  </div>

  <div class="language-skills">
    <h2>Language Skills</h2>
    <hr>

    

As you can see I store all of my data in SQLAlchemy database, but I want to be able to edit or make it with forms. I want to make a function which will allow me to do it but in order to do that i have to create a correct form inside my function because one of the html elements contains the date and the other doesn't. Here's a 'skeleton' of my function for better undersanding:

@app.route("/make", methods=["GET", "POST"])

    def make():
        # if this is element related to this form:
        #     create related form
        # else:
        #     but if its related to the second one create related form

Is there a way for if statement, to distinguish which html element i want to edit, or make in order for it to create a correct form?

Aucun commentaire:

Enregistrer un commentaire