Feature(s) impacted
Sorting by a foreign key (relationship) column
Observed behavior
When I sort a table by a column which is a foreign key to another table, I get a Bad Request error. I believe this is because my foreign key refers to a table who’s primary key is not named “id”.
For example, if I sort my table by a column called “age_category”, which points to a table with a primay key column named “term”, I get a Bad Request error. When I go into the network tab, it looks like the Forest admin UI is making a request to the backend with the query parameter sort=-age_category.id
. If I change this value to sort=-age_category.term
, the request works and the page loads.
Additionally, if I edit the ForestAdmin UI URL in my browser, the frontend seems to make a correctly formatted request to the backend.
- Normally, when I sort a column, I’m redirected to the URL:
https://app.forestadmin.com/GumboUI/Development/DepMap/data/model/index?sort=-age_category - But if I edit this URL to the following, it works:
https://app.forestadmin.com/GumboUI/Development/DepMap/data/model/index?sort=-age_category.term
Expected behavior
The sorting works without needing to manually edit the URL.
Failure Logs
See above debugging details.
Context
- Project name: GumboUI
- Team name: DepMap
- Environment name: All environments
- Agent type & version: django-forestadmin v.1.3.2
- Recent changes made on your end if any: None. This has been an issue for us for a while now.