'Django dynamically modifying querysets
I've got a Django 2.2.28 application running on Python 3.7.7 and I'm trying to add what I think is an unusual query filter. One of the displays is generated by a queryset that is filtered in the normal way against a PostgreSQL database. This data is presented in using a paginator. I'm being asked to add a filter the data on the display by an additional filter using data that comes from a REST API call (not the database). A simplified presentation to explain what's desired, let's say I have a display with 2 columns, Id and Name that comes from the database:
Id Name
1 George
2 Anne
3 Susan
4 Mark
The add ask is to add a 3rd column for Status, which comes from a REST API by passing a list of Id values. Adding the Status to the above display would theoretically present this if the list of Ids were passed to the REST API:
Id Name Status
1 George True
2 Anne False
3 Susan True
4 Mark False
The users would like to filter the display based on the Status (True/False) and still have a full page of results (4). The problem is if the user filters for only Status == True, I want to filter out Id 2 and 3. But that makes the display only have 2 results. I need to have this:
Id Name Status
1 George True
3 Susan True
6 Helen True
10 Ben True
To create this display I have to make additional REST API calls with lists of additional Ids till I can fill out the display with 4 results. This means looking forward for Id values till I get enough results to populate the display. I also need to keep the pagination (at least ... links)
Any ideas, suggestions, etc would be very welcome! Thanks!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
