def addAuthors(repo_id): repository = DeployA.objects.get(pk=repo_id) realRepo = Repo(repository.repository.location) for commit in realRepo.iter_commits('master', max_count=10): if not Author.objects.filter(email=commit.author.email): author = Author() author.email = commit.author.email author.name = commit.author.name print(author.email) print(author.name) author.save() repository.authors.add(author) repository.save()