Skip to content

Commit

Permalink
fix ordering expression for space description
Browse files Browse the repository at this point in the history
  • Loading branch information
lukavdplas committed Sep 27, 2024
1 parent bc43046 commit b1152cc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions backend/space/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ class SpaceDescription(EntityDescription, models.Model):

class Meta:
ordering = [
models.F("structures__identifiable").desc(nulls_last=True),
models.F("settlements__identifiable").desc(nulls_last=True),
models.F("regions__identifiable").desc(nulls_last=True),
models.Case(
models.When(structures__identifiable=True, then=1),
models.When(settlements__identifiable=True, then=2),
models.When(regions__identifiable=True, then=3),
default=None,
).asc(nulls_last=True),
]

regions = models.ManyToManyField(
Expand Down

0 comments on commit b1152cc

Please sign in to comment.