def get_has_voted(self, obj): return Vote.has_voted(self.context['request'].user, obj)
def validate(self, data): data['voter'] = self.context['request'].user if Vote.has_voted(data['voter'], data['project']): raise exceptions.ValidationError('You already voted.') return data
def validate(self, data): if Vote.has_voted(data['voter'], data['project']): raise exceptions.ValidationError('You already voted') return data