nansencenter / django-geo-spaas-rest-api

REST API for django-geo-spaas
GNU General Public License v3.0
1 stars 1 forks source link

Generic filters #19

Closed aperrin66 closed 3 years ago

aperrin66 commented 3 years ago

Upgrade the filters by enabling Django style lookups.

For example, it is now possible to use the following request to find datasets from the VIIRS instrument: GET <api_root>/datasets/?source__instrument__short_name=VIIRS

See the modified README for more details.

The previous version of the API is kept in the v1 folder for now. It is not supposed to be modified, and won't be included in the CI unit tests. If needed, tests on the v1 can be run locally by using the v1/runtest.py script.

aperrin66 commented 3 years ago

you define that StrictFilterSetclass and use it in order to receive error message Invalid lookups found: in your API responses. DO you use it in the downstream in some other place? or just for unifying and standardizing the error output of API you do that?

Without this StrictFilterSetclass, there is no error when there an invalid lookup in the request. Instead, the whole list of objects is returned unfiltered, which can be very confusing. As for the usage of this class, all filtersets defined in filters.py inherit from it.

opsdep commented 3 years ago

Previously, you have mentioned that StrictFilterSet class is needed. But now you have removed that StrictFilterSet class! What would happen if a bad api request comes in? unfiltered objects are returned in the reply?

aperrin66 commented 3 years ago

Previously, you have mentioned that StrictFilterSet class is needed. But now you have removed that StrictFilterSet class! What would happen if a bad api request comes in? unfiltered objects are returned in the reply?

It is not strictly needed, it's just less confusing for the user to receive an error instead of unfiltered data. Unfortunately, the StrictFilterSet interferes with query arguments which are not lookups, so it is not usable.