Created
September 24, 2020 01:25
-
-
Save toxinu/137663f558cd056449556caf300dd525 to your computer and use it in GitHub Desktop.
blog/filtering-and-ordering-with-restless
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class APIFilterMixin: | |
| allowed_fields_filter = [] | |
| def filter(self, queryset): | |
| filters = {} | |
| for arg in self.request.GET: | |
| if arg in self.allowed_fields_filter: | |
| filters.update({arg: self.request.GET.get(arg)}) | |
| return queryset.filter(**filters) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment