Changes between Version 1 and Version 3 of Ticket #32685


Ignore:
Timestamp:
Apr 26, 2021, 6:40:37 AM (4 years ago)
Author:
Barney Szabolcs
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #32685

    • Property Component UncategorizedDatabase layer (models, ORM)
    • Property Resolutionwontfix
    • Property Status newclosed
    • Property Type UncategorizedNew feature
  • Ticket #32685 – Description

    v1 v3  
    2020from django.db.models import Case, When
    2121
    22 preserved = Case(*[When(my_field=val, then=pos) for pos, val in enumerate(my_values)])
     22preserved = Case(*[When(my_field=val, then=pos) for pos, val in enumerate(my_values)], default=len(my_values))
    2323queryset.filter(my_field__in=my_values).order_by(preserved)
    2424}}}
Back to Top