code: def update_or_create_candidate(
          self, candidate, aggregable=True, uncontested=False
      ):
          
          candidate_election, c = CandidateElection.objects.update_or_create(
              candidate=candidate,
              election=self,
              defaults={"aggregable": aggregable, "uncontested": uncontested},
          )
  
          return candidate_election
docs: Create a CandidateElection.