title: Remove objects from query if None or Null
body: <p>I am trying to build a query that takes form data and removes any <code>None</code> or <code>" "</code> submissions but I'm not sure how to approach the logic.  Here is the code;</p>
  
  <pre><code>@app.route('/filterassets', methods=['GET', 'POST'])
  def searchassets():
  form = FilterAssetsForm()
  results = None
  if request.method == "POST":
      if form.validate_on_submit():
          try:
              horsepower = form.horsepower_search.data
              voltage = form.voltage_search.data
              rpm = form.rpm_search.data
              results = Motor.query.filter_by(horsepower=horsepower, voltage=voltage, rpm=rpm).all()
          except Exception as e:  
              flash(e)
              db.session.rollback()
          return render_template('filterassets.html', form=form, results=results)
  return render_template('filterassets.html', form=form)
  </code></pre>
  
  <p>Because it's the backend of a page that lets users filter, rather than explicitly search, some form data is empty.  This is causing the query to search for results where one or more forms == None.</p>
  
  <p>Example: User enters 100 in the horsepower form and leaves RPM and Voltage blank. The query returns no results even though there are rows with 100 horsepower because it is looking for rows where Horsepower == 100 and RPM and Voltage == None. </p>
  
  <p>I've tried using <code>filter(None, object)</code> with no success, and think the solution may be somewhere in using <code>kwargs</code>.</p>
  
  <p>I know I need to pass all the form data to something that will remove <code>None</code> or <code>Null</code> entries, then pass it onto the final <code>Motor.query.filter_by</code> argument, I just don't know how.</p>