Skip to content

Instantly share code, notes, and snippets.

@svfat
Created May 22, 2015 19:47
Show Gist options
  • Save svfat/2300c7420776289ecad5 to your computer and use it in GitHub Desktop.
Save svfat/2300c7420776289ecad5 to your computer and use it in GitHub Desktop.
Django - Get queryset from filtered objects with parameters from request
from django.views.generic import ListView
from sampleapp.models import Sample
class CustomListView(ListView):
def get_queryset(self):
query_dict = self.request.GET
return Sample.objects.filter(**query_dict.dict())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment