I haven’t been able to find the Movies.py module… where should I look or acquire this module to look at the Paging code?
The code you have to change is in db.py as indicated by:
Modify the method get_movies in db.py to allow for paging. You can see how the page is parsed and sent in the api_search_movies method from movies.py.
Here lies my problem, I can’t find the movies.py file?
It says to change the file db.py, why do you want the file movies.py.
To see how the page is parsed and sent in the api_search_movies method from movies.py.
can you tell me where to find the module or email it to me?
(mflix) : steevej @ asus-laptop ; find . -name movies.py
Thanks… must be having a senior moment … taking this class plus and “R” online class…
I am having the same problem. I ran all the functions in jupyter notebook too to verify and got the right results too.
I solved my issue…lets see your paging function in db.py
My function LIMIT is ignored. I have tried to hardcode numbers there, but I anyway got all result without any limit. What I did wrong?
Even in mongo shell, I have problems with LIMIT
cursor.limit didn’t work for me, so I had to add limit and skip to cursors in
The way you use limit does not correspond to the described syntax.
You have to use:
cursor = db.movies.find(…).limit(10)
That’s why you get ‘query already executed’. Please consult the documentation:
In shell I have agreed, but what about Python? Why when I use
movies = cursor.limit(10) its ignored?
total_num_movies = 0 total_num_movies = db.movies.count_documents(query) """ Ticket: Paging """ movies = cursor.skip(page*movies_per_page).limit(movies_per_page) return (list(movies), total_num_movies)
total_num_movies = 0
total_num_movies = db.movies.count_documents(query)
""" movies = cursor.skip(page*movies_per_page).limit(movies_per_page) return (list(movies), total_num_movies)
i added if page==0 after total_num_movies=0
the total_num_movies = db.movies.count_documents(query) should be the if statement block code