Articles → DJANGO → Different functions of queryset in Django

Different functions of queryset in Django






What is queryset?





Functions













Click to Enlarge


Filter




def get_list(request):
    template_name = "get_list.html"
    queryset = MyNewScreen.objects.all()
    queryset = queryset.filter(name="test123")
    print(queryset.count())
    context = {"list": queryset}
    return render(request, template_name, context)



Click to Enlarge


Update




def get_list(request):
    template_name = "get_list.html"
    queryset = MyNewScreen.objects.all()
    queryset.update(name="test567")
    print(queryset.count())
    context = {"list": queryset}
    return render(request, template_name, context)





Click to Enlarge


Exclude




def get_list(request):
    template_name = "get_list.html"
    queryset = MyNewScreen.objects.all()
    queryset = queryset.exclude(name="test44")
    print(queryset.count())
    context = {"list": queryset}
    return render(request, template_name, context)



Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Monday, January 13, 2020

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250