Skip to content

Commit

Permalink
Order blogs by release at
Browse files Browse the repository at this point in the history
  • Loading branch information
JElgar committed Sep 30, 2024
1 parent b5e9e85 commit 16feb09
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions causes_service/blogs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ def clean(self):

def __str__(self) -> str:
return self.title

class Meta:
indexes = [
models.Index(fields=['-release_at']),
]

2 changes: 1 addition & 1 deletion causes_service/blogs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ class BlogViewSet(viewsets.ReadOnlyModelViewSet):
lookup_field = 'slug'

def get_queryset(self):
return Blog.objects.filter_active(is_active_at=timezone.now())
return Blog.objects.filter_active(is_active_at=timezone.now()).order_by('-release_at')

0 comments on commit 16feb09

Please sign in to comment.