Home > front end >  DRF pagination with filtering
DRF pagination with filtering

Time:09-02

I have a Django Rest Framework project which is serving up (amongst other things) events.

In general, as there could be thousands of events, I prefer to keep the API calls paginated in order to stop the front end API calls from taking too long.

I can use this paginated route to produce a table on the front end which will reflect each page in the returned response.

Up until now, all good.

However, I also want to add a dropdown filter above the table where users can select any of the possible venues that the events are at. But to get an exhaustive list of all the possible venues for the dropdown list, I'll need to go and fetch ALL of the events anyway!

Is there another way to do this? Or is a non-paginated events route my only choice?

CodePudding user response:

It's in the django rest framework documentation, in Filtering section

CodePudding user response:

If the venue requires all the events (thousands) it will not be a good idea to fetch it in the frontend, Try to deal with that from the backend and serve venues in the frontend based on the requirements.

  • Related