fix: model ordering (#521)

* fix: model ordering

* fix: my pages and create by others pages
This commit is contained in:
pablohashescobar 2023-03-25 11:14:05 +05:30 committed by GitHub
parent c6ba93da72
commit 5152deb2d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 51 additions and 10 deletions

View file

@ -91,7 +91,7 @@ class ProjectViewSet(BaseViewSet):
projects = (
self.get_queryset()
.annotate(is_favorite=Exists(subquery))
.order_by("-is_favorite")
.order_by("name", "-is_favorite")
)
return Response(ProjectDetailSerializer(projects, many=True).data)
except Exception as e:
@ -101,7 +101,6 @@ class ProjectViewSet(BaseViewSet):
status=status.HTTP_400_BAD_REQUEST,
)
def create(self, request, slug):
try:
workspace = Workspace.objects.get(slug=slug)