Remove duplicates in a Django query

前端 未结 6 1189
北恋
北恋 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:16

    You can also use set()

    email_list = set(Emails.objects.values_list('email', flat=True))
    

提交回复
热议问题