Skip to content

Instantly share code, notes, and snippets.

@walison17
Last active August 20, 2018 20:10
Show Gist options
  • Save walison17/34f85805907db99ee9d7f6dc93000f9d to your computer and use it in GitHub Desktop.
Save walison17/34f85805907db99ee9d7f6dc93000f9d to your computer and use it in GitHub Desktop.
class SlugFilterBackend(filters.BaseFilterBackend):
def filter_queryset(self, request, queryset, view):
slug = request.query_params.get('slug')
if slug:
for s in slug.split(','):
queryset.filter(slug=s)
return queryset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment