Skip to content
Advertisement

How do I get all the commented TV and movie scores in descending order? django

What we want to achieve.

I want to sort the movies according to their star ratings and filter the movies with lower rating than the specified threshold. 2. get the IDs of Movie and TV that are commented in the View, and get the data and score by url one by one. 3. Return it to the html and display the movies and TVs in descending order of score.

Present condition

The tmdb API is used to retrieve movie information. And the model movie and TV have only ID and stars(score). From here, only those with stars are returned to html.

I want to ask a question.

And if score is selected, how can I make it appear in descending score order? data = requests.get (f “https://api.themoviedb.org/3/tv/{tv_id}?api_key={TMDB_API_KEY}&language=en-US”). Now you can get the information of tv.

JavaScript
JavaScript
JavaScript
JavaScript
JavaScript

Advertisement

Answer

You have reversed() which usually reverses the order of a list – there is a better way of doing this with order_by and using - in front of your field to change whether it is in ascending or descending order:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement