Skip to content

Instantly share code, notes, and snippets.

View lane-eb's full-sized avatar

Lane Zhang lane-eb

  • East Bay
  • Suzhou
View GitHub Profile
@lane-eb
lane-eb / .py
Created September 30, 2020 08:27
Django query solution to replace `values_list('repo__name')`.
# IMO, This is the best.
def contributor_repo_names(self, organization):
repo_ids = Commit.objects.filter(
repo__in=organization.repos.all(),
committer=self
).values_list('repo_id', flat=True).distinct('repo_id')
return list(
GitRepo.objects.filter(repo_id__in=repo_ids).values_list('name', flat=True)
)