How to I return the length of the get_by_id ??
For example I have
query = Model.get_by_id(1)
I tried
if len(query) == 1 and if query.count() == 1 both not working
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
*Model.get_by_id()* returns only a single object if a single id is passed, it returns a list of objects only when a list of id’s is passed, which means it obvioulsy won’t have len and count.
if you want to check if query is not None, you can simply give
if you want to get a list of objects based on keys, use get: