Skip to content

Instantly share code, notes, and snippets.

@JorgeMichelena
Created September 19, 2022 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JorgeMichelena/ffb11721719271c9d116cd65899b2ee7 to your computer and use it in GitHub Desktop.
Save JorgeMichelena/ffb11721719271c9d116cd65899b2ee7 to your computer and use it in GitHub Desktop.
targets = (
    User.objects
    .annotate(
        match_count=Count("targets__matches_1") + Count("targets__matches_2")
    ).order_by("-match_count")
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment