Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

django bring specific values first

User.objects.annotate(is_me=Case(
            When(pk=request.user.pk, then=Value(True)), 
            When(pk__ne=request.user.pk, then=Value(False)),
         output_field=BooleanField())
 ).order_by('-is_me')
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #django #bring #specific #values
ADD COMMENT
Topic
Name
9+5 =