At the moment the front of the movie card says None in large letters. This is because we have not assigned a .ranking
.
Instead, we want it to display the ranking of the movie according to our rating. For example if we gave The Matrix a rating of 9.2 and Spirited Away was rated 9.5 and those are the only 2 movies we've added then it should display:
If we add another movie and it had the highest rating among the movies, then it should be ranked according to it's rating.
e.g. If Matrix (9.3), Spirited Away (9.5), Parasite (9.9)
But if we edit the rating so that it becomes: Matrix (9.3), Spirited Away (9.5), Parasite (8.9)
Then this is what should happen:
You can assign a movie ranking when you navigate to the home route (/
) . You'll have to work with the objects (Result and ScalarResult) that you're getting back from your database query. See if you can find a way to turn your data into a python list.
HINT 1: Check out how order_by()
is used in the example: https://flask-sqlalchemy.palletsprojects.com/en/3.1.x/quickstart/#query-the-data
HINT 2: You don't need to change any code in index.html
HINT 3: You only need to change the code in the home()
function.
You can download the COMPLETED PROJECT from this lesson's resources.