I have a form which takes a list of inputs via html (searchinput) and adds it to a query in python.
searchterms = []
searchterms = request.values.get('searchinput').strip().split(', ')
filtered = pd.concat([df.query("Drug.str.contains('|'.join(@searchterms), na=False, case=False, regex=True)", engine='python')])
return render_template('drugsafety.html', tables=[filtered.to_html(classes='data')], titles=['na', 'Drug List'])
This gives
AttributeError: 'NoneType' object has no attribute 'strip'
If I then feed in a value like searchterms = ["foobar"] it works and will even take the form inputs without error.
How can I get around this initial needing a value to boot it into life?
edit
searchterms = []
if searchterms is not None:
searchterms = request.values.get('searchinput').strip().split(', ')
filtered = pd.concat([ df.query("Drug.str.contains('|'.join(@searchterms), na=False, case=False, regex=True)", engine='python')])
else:
searchterms = ["Foo"]
Thanks for any help