So i have this html
<label class="continer">Empresa Confidencial
<input type="checkbox" id="confidencial" name="confidencial" value="0">
<span class="checkmark"></span>
</label>
proyect.py
def editar_(confidencial,estado,id):
cur = mysql.connection.cursor()
cur.execute('UPDATE proyecto set EMPRESA_CONFIDENCIAL=%s,estado=%s where PK_PROYECTO=%s', (confidencial,estado, id,))
mysql.connection.commit()
adminviews.py
@app.route("/editar", methods=["POST"])
def editar():
print('.................................................................................')
id = request.form['id']
estado = request.form.get('estado')
confidencial = request.form.get('confidencial')
print(id,str(estado), str(confidencial))
pr.editar_(confidencial,estado,id)
return redirect(url_for('empresasT'))
And i need to get the value "1"
or "0"
to send it to the database, the problem is that when i run the code, without the "confidencial"
in proyect.py
and adminvie.py
, it runs and make changes in the database, but when i try again with the "confidencial"
, and make a change in the checkbox
, if the checkbox is checked and i unchecked it the value is none, but if i leave it checked, the value is the one by default, the console it says that the value is null, MySQLdb._exceptions.OperationalError: (1048, "Column 'EMPRESA_CONFIDENCIAL' cannot be null")
, the process is not getting the value "1"
or "0"
from the checkbox
after the modification, but the other values that i got like id and estado does, i think is the if
statement, how can i get the value from the checkbox
in the html using the if
statement
Aucun commentaire:
Enregistrer un commentaire