Remove duplicates in a Django query

前端 未结 6 1188
北恋
北恋 2020-12-08 06:39

Is there a simple way to remove duplicates in the following basic query:

email_list = Emails.objects.order_by(\'email\')

I tried using

6条回答
  •  误落风尘
    2020-12-08 07:19

    You can chain .distinct() on the end of your queryset to filter duplicates. Check out: http://docs.djangoproject.com/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.distinct

提交回复
热议问题