DevBJ

Main navigation

  • Home
  • About
  • Style Guide
  • Tags
  • Download
November 21, 2023

ORM 중복 제거 – distinct

By Bongjun Hur

https://django-orm-cookbook-ko.readthedocs.io/en/latest/duplicate.html

>>> duplicates = User.objects.values(
    'first_name'
    ).annotate(name_count=Count('first_name')).filter(name_count__gt=1)
>>> duplicates
<QuerySet [{'first_name': 'John', 'name_count': 3}]>

여기 링크 글이 좋음 – https://unocoings.tistory.com/12

Share: Twitter Facebook
Bongjun Hur's Picture

About Bongjun Hur

BJ is a dev.

Seoul, Korea https://devbj.com
Twitter GitHub Instagram LinkedIn

© Scriptor all rights reserved. Theme by JustGoodThemes.

Back to the top ↑