Skip to content

Instantly share code, notes, and snippets.

@bertavincze
Created April 17, 2020 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bertavincze/ac626f6409f286e5876076c9f6da7810 to your computer and use it in GitHub Desktop.
Save bertavincze/ac626f6409f286e5876076c9f6da7810 to your computer and use it in GitHub Desktop.
class PeopleFilter(FilterSet):
class Meta:
model = PeopleModel
fields = {'name': ['eq', 'ne', 'in', 'ilike'],
'planet_id': ['eq', 'ne', 'in', 'gt', 'lt', 'gte', 'lte']}
class PlanetsFilter(FilterSet):
class Meta:
model = PlanetModel
fields = {'id': [...], # shortcut!
'name': ['eq', 'ne', 'in', 'ilike']}
class MyFilterableConnectionField(FilterableConnectionField):
filters = {PeopleModel: PeopleFilter(), PlanetModel: PlanetsFilter()}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment