Answer the question
In order to leave comments, you need to log in
How to efficiently select the next largest element in Django?
Hello.
Situation
There is an element model where there is a name and number of likes
Element
title = models.CharField()
number_of_likes = models.IntegerField()
Answer the question
In order to leave comments, you need to log in
Element.objects.filter(number_of_likes__gt=el.number_of_likes).order_by('number_of_likes').first()
Because in each case you are comparing $day with the result of the formula calculation.
Your entry is equivalent to the following:
if ($day == ($day == 1 && $day <= 5)) { }
elseif ($day == ($day === 6 && $day === 7)) {}
elseif ($day == ($day == 0 && $day > 7)) {}
($day == 1 && $day <= 5)
executed only if $day == 1. ($day === 6 && $day === 7)
never executed. ($day == 0 && $day > 7)
also never executed. switch ($day) {
case 1:
case 2:
case 3:
case 4:
case 5:
echo ... ;
break;
case 6:
case 7:
echo ... ;
break;
default:
echo ... ;
break;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question