Description
The dashboard list APIs support sorting by related fields such as organization (org) or campus. However, when sorting is applied, the API sorts by the UUID of the related object instead of the human-readable name/title.
This results in lists that appear randomly ordered to users, since UUID strings do not correspond to meaningful alphabetical ordering.
This affects usability in dashboards where users expect organizations or campuses to be sorted alphabetically.
Goals
Expected Outcome
When a dashboard list API is called with sorting parameters such as ?sortBy=org, the results should be ordered alphabetically based on the organization's title (for example organization__title). The same behavior should apply for campus sorting using the campus name/title field.
The API should return results in a predictable alphabetical order that is meaningful to users.
Acceptance Criteria
Implementation Details
The issue likely occurs because the query ordering uses the related object's UUID field instead of a readable attribute.
Instead of ordering by the related object ID (e.g., organization_id), the queryset should order by the related object's title field such as:
organization__title
campus__title
The sorting logic inside the queryset or filter backend should be updated accordingly.
Mockups / Wireframes
Not required since this is a backend API issue.
Product Name
mulearn
Project Name
[BUG] Incorrect Sorting on Organization/Campus Lists
Tech Skills Needed
Python, Django, REST APIs, Database Query Optimization
Mentor(s)
@Mentor1 @mentor2
Complexity
Medium
Category
Bug
Sub Category
Backend, API, Reproducible
Description
The dashboard list APIs support sorting by related fields such as organization (
org) or campus. However, when sorting is applied, the API sorts by the UUID of the related object instead of the human-readable name/title.This results in lists that appear randomly ordered to users, since UUID strings do not correspond to meaningful alphabetical ordering.
This affects usability in dashboards where users expect organizations or campuses to be sorted alphabetically.
Goals
organization__titleinstead of UUIDorgandcampusExpected Outcome
When a dashboard list API is called with sorting parameters such as
?sortBy=org, the results should be ordered alphabetically based on the organization's title (for exampleorganization__title). The same behavior should apply for campus sorting using the campus name/title field.The API should return results in a predictable alphabetical order that is meaningful to users.
Acceptance Criteria
?sortBy=orgorders results alphabetically by organization title?sortBy=campusorders results alphabetically by campus nameImplementation Details
The issue likely occurs because the query ordering uses the related object's UUID field instead of a readable attribute.
Instead of ordering by the related object ID (e.g.,
organization_id), the queryset should order by the related object's title field such as:organization__titlecampus__titleThe sorting logic inside the queryset or filter backend should be updated accordingly.
Mockups / Wireframes
Not required since this is a backend API issue.
Product Name
mulearn
Project Name
[BUG] Incorrect Sorting on Organization/Campus Lists
Tech Skills Needed
Python, Django, REST APIs, Database Query Optimization
Mentor(s)
@Mentor1 @mentor2
Complexity
Medium
Category
Bug
Sub Category
Backend, API, Reproducible