Created
September 24, 2020 01:25
-
-
Save toxinu/6428eac21cb525e43884354d51f56605 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 PizzaResource(APIFilterMixin, DjangoResource): | |
| preparer = FieldsPreparer(fields={ | |
| 'id': 'id', 'name': 'name'}) | |
| allowed_fields_filter = [ | |
| 'name', 'name__startswith', | |
| 'price', 'price__lte', 'price__gte', | |
| 'ingredients__ingredient__name'] | |
| def list(self): | |
| qs = Pizza.objects.all() | |
| return self.filter(qs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment