def __init__(self, *args, **kwargs): super(ChallengeSerializer, self).__init__(*args, **kwargs) context = kwargs.get("context") if context and context.get("request").method != "GET": challenge_host_team = context.get("challenge_host_team") kwargs["data"]["creator"] = challenge_host_team.pk else: self.fields["creator"] = ChallengeHostTeamSerializer()
def __init__(self, *args, **kwargs): super(ChallengeSerializer, self).__init__(*args, **kwargs) context = kwargs.get('context') if context and context.get('request').method != 'GET': challenge_host_team = context.get('challenge_host_team') kwargs['data']['creator'] = challenge_host_team.pk else: self.fields['creator'] = ChallengeHostTeamSerializer()