Articles → DJANGO → Different Functions Of Queryset In Django
Different Functions Of Queryset In Django
What Is Queryset?
Functions
- Filter
- Update
- Exclude
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