How flask uses flask request to get input values with the same name attribute in a form

the code is as follows:

view.py

.
@ approval.route ("/ submit", methods= ["GET"," POST"])
@ login_required
def _ submit ():

form = LEForm()
if current_user.can(Permission.WRITE) and request.form.get("submit", None) == "":
    post = Post(
        w=form.w.data -sharp-sharp-sharp-sharp-sharp-sharp-sharp-sharp-sharp-sharp-sharp-sharp-sharp-sharp-sharp-sharp-sharp-sharp-sharp-sharp-sharp-sharp-sharp-sharp
    )
    db.session.add(lepost)
    db.session.commit()

.

html

.
< td > < input type= "text" id= "w_location" name= "w_location" value= "first value" placeholder= "> < / td >
< td > < input type=" text "id=" w_location "name=" w_location "value=" second value "placeholder=" > < / td >
< td > < input type= "text" id= "w_location" name= "w_location" value= "third value" placeholder= "> < / td >
...

in this way, you can only receive the first value, and only one piece of data has been created in the database. How can you automatically receive three values and create three pieces of data in the database? I"m much obliged.

Mar.18,2022

Why are each of your id and name the same?


it is recommended that you give id and name different values.


for 3 years, answer specifically
to build the same form for name is often a rigid requirement, and FLASK certainly won't have such a low-level lack of function.
request.form returns an ImmutableMultiDict type.
luckily the ImmutableMultiDict object has a lists method. It converts it to a dictionary with a unified key that contains a list of values.

from werkzeug import ImmutableMultiDict
-sharpd = request.form
d = ImmutableMultiDict ([('name',' boom'), ('extension',' pdf'), ('extension',' doc')])
dict (d.lists ())

-sharp returns:
{'name': [' boom'], 'extension': [' pdf', 'doc']}

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b35a29-2acf3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b35a29-2acf3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?