def create(self, validated_data):
new_event = validated_data.pop('event', None)
existing_event = validated_data.pop('event_id', None)
if not existing_event:
if not new_event:
raise ValidationError({
'event': 'You must have a new event or event_id attached to this associated event.'
})
else:
existing_event = EventSerializer().create(new_event)
associated_event = AssociatedEvent(
event=existing_event,
receiving_person=validated_data.get('receiving_person_id'),
creating_person=self.context['user'].person
)
associated_event.save()
return associated_event
评论列表
文章目录