Dimitris Kougioumtzis Blog About technology

Dynamic queryset

Category Django

Posted on Aug. 22, 2017



Dynamic queryset class based view django


1
2
3
4
5
6
7
def get_queryset(self):
   qs = super().get_queryset()
   model = self.model
   kwargs = dict((field, value) for field, value
                      in self.request.GET.items() if value)
   qs = model.objects.filter(**kwargs)
   return qs

About

My name is Dimitris Kougioumtzis and i work as a Web developer at Rapidbounce Company

Elsewhere