Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

handle queries in ListView django

class ProfileList(ListView):
    template_name = 'your_template.html'
    model = Profile

    def get_queryset(self):
        query = self.request.GET.get('q')
        if query:
            object_list = self.model.objects.filter(name__icontains=query)
        else:
            object_list = self.model.objects.none()
        return object_list
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #handle #queries #ListView #django
ADD COMMENT
Topic
Name
7+9 =