def get_candidates_by_party(self):
        """
        Get CandidateElections serialized into an object with
        party-slug keys.
        """
        candidate_elections = CandidateElection.objects.filter(election=self)

        return {
            ce.candidate.party.slug: ce.candidate for ce in candidate_elections
        }
def get_candidates_by_party ( self ) : candidate_elections = CandidateElection . objects . filter ( election = self ) return { ce . candidate . party . slug : ce . candidate for ce in candidate_elections }
Get CandidateElections serialized into an object with
        party-slug keys.