I have the datetime filled with auto_now=True
Database is mysql.
Range queries won’t work for me directly.
Is there any one liner for this?
For simplicity, how can I get 10 rows with highest values for a field(let it be Integerfield) ?
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.
For model
Modelwith integer fieldfield, this should work:If you want django to have an index on the field, you need to define it in the model with db_index option:
Regular database index should work even if your asking for the highest values.