Skip to content

Instantly share code, notes, and snippets.

@toxinu
Created September 24, 2020 01:25
Show Gist options
  • Save toxinu/6428eac21cb525e43884354d51f56605 to your computer and use it in GitHub Desktop.
Save toxinu/6428eac21cb525e43884354d51f56605 to your computer and use it in GitHub Desktop.
blog/filtering-and-ordering-with-restless
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