You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i has created_at field, i need to set default ordering = -created_at (latest first)
if I set ordering in quaryset , can't work (ninja-extra change the order)
@http_get(
path="",
response={
HTTPStatus.OK: PaginatedResponseSchema[CampaignSchema],
HTTPStatus.INTERNAL_SERVER_ERROR: error_schema
},
summary="Campaign List",
description="This endpoint retrieves a list of campaigns.",
url_name="campaign_list"
)
@paginate()
@ordering(Ordering, ordering_fields=['name'])
@searching(Searching, search_fields=['name'])
def list(self):
records = self.model.objects.all().order_by("-created_at")
return records
The text was updated successfully, but these errors were encountered:
Elixir-MeetThoriya
changed the title
How to set Default ordering in list api ??
How to set Default ordering in list api using @ordering decorator ??
Jan 9, 2025
@Elixir-MeetThoriya, the ordering fields are particularly in this ['-created_at', 'name']. Ordering by name happened first and ordering by name followed. So the result you see is actually correct
i has created_at field, i need to set default ordering =
-created_at
(latest first)if I set ordering in quaryset , can't work (ninja-extra change the order)
The text was updated successfully, but these errors were encountered: