1

Alright, so I'm trying to allow a user to search for a movie/TV Show in the database I've set up using sqlalchemy. I followed along with a tutorial and was able to print all the movies out to the screen from my database using this code:

<div class="row">
      <div class="col-sm-4 portfolio-item">
        {% for movie in movies %}
        <h2 class="post-title">{{ movie.title }}</h2>
        <p>{{ movie.description }}</p>
        {% endfor %}
      </div>
    </div>

But, when I tried adding the search feature, nothing would show up. When I made the search I got back this result:

SELECT "movieTV".id AS "movieTV_id", "movieTV".title AS 
"movieTV_title", "movieTV"."releaseDate" AS "movieTV_releaseDate", 
"movieTV".producer AS "movieTV_producer", "movieTV".description AS 
"movieTV_description", "movieTV".genre AS "movieTV_genre" 
FROM "movieTV" 
WHERE null

Here is my search function:

@app.route('/', methods=['GET', 'POST'])
def index():
    movies = MovieTV.query.all()
    error = None
    return render_template('index.html', error=error, movies=movies)


@app.route('/search')
def search():
    movies = MovieTV.query.whoosh_search(request.args.get('query'))
    return render_template('index.html', movies=movies)
humbleCoder
  • 463
  • 1
  • 5
  • 18

0 Answers0