Answer the question
In order to leave comments, you need to log in
Django output slice using order_by('?')[:n]?
Instead of 5 I want to put the variable n
answers = Answer.objects.all().order_by('?')n I take from the database. How to do what you want? Answer base, take everything, mix, take the first n and send to html
answers = answers[:5]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question