Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Flask_SQLAlchemy is claiming my value is not boolean

# At the top
from distutils.util import strtobool

@app.route("/", methods=["GET", "POST"])
def home():
    if request.form:
        try:
            form_status = strtobool(request.form.get("status").lower())
            status = Projects(status=form_status)
            db.session.add(status)
            db.session.commit()
        except ValueError:
            # Handle the error - e.g. flash a message to the user
            flash("Invalid input")
    return render_template("home.html")
Comment

PREVIOUS NEXT
Code Example
Python :: What is the right way to do such import 
Python :: HTML default value fo radio button input type based on python variable 
Python :: python pyramid pattern 
Python :: app.callback output is not defined 
Python :: Flask/Werkzeug, how to return previous page after login 
Python :: Creating 2-dimesional array 
Python :: Filling a missing value in a pandas data frame with an if statement based on a condition 
Python :: tdlib python 
Python :: python regex with f-string 
Python :: patterns and matcher nfa python code 
Python :: how to close python in terminal 
Python :: ring get the type a given path (file or directory) 
Python :: store image in django postprocessimage in django storage 
Python :: ring Type Hints Library 
Python :: get length of list python 
Python :: pairplot seaborn legend best position set 
Python :: talib 
Python :: python list of datetimes as type string 
Python :: insertar en una lista anidada python 
Python :: create new column pandas and order sequence 
Python :: python get part of jason from string 
Python :: django reverse accessor clashes for abstract class 
Python :: how to shorten turtle. to t. 
Python :: how can space be bent 
Python :: logistic regresion heart disease python 
Python :: np array blurring 
Python :: input character in python like getchar in c 
Python :: pyteal atomic transfer 
Python :: backslashing in an interactive session in python 
Python :: how to connect smartphone camera to opencv python 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =