Python Django Filter Distinct Example Tutorial
Published On: 22/08/2022 | Category:
Django

Hi Dev,
Now, let's see tutorial of python Django filter distinct example. Here you will learn django queryset distinct by field. We will use django values list distinct. I would like to share with you How to find distinct field values from queryset in django.
Django distinct() method in django to remove the duplicate records from the queryset.
You can use these examples with django3 (Django 3) version.
let's see bellow example here you will learn python Django filter distinct example.
Django Admin Interface:

Example
In this example we will use the same Member model. And here is the example of the distinct() method.
views.pyfrom django.http import HttpResponse from core.models import Member def index(request): queryset = Member.objects.values('country').distinct() print(queryset) return HttpResponse(queryset)Output
[ { 'country': 'India' }, { 'country': 'United States' } ]
I Hope It will help you....