def create()

in pulseapi/entries/serializers/base.py [0:0]


    def create(self, validated_data):
        """
        We override the create method to make sure we save related creators
        as well and setup the relationship with the created entry.
        """
        user = self.context.get('user')
        creator_data = validated_data.pop('related_entry_creators', [])
        entry = super().create(validated_data)

        if user and entry.published_by_creator:
            creator_data.append({'profile': user.profile})

        for data in creator_data:
            if not data.pop('profile_committed', True):
                data['profile'].save()
            try:
                with transaction.atomic():
                    EntryCreator.objects.create(entry=entry, **data)
            except IntegrityError:
                # We ignore duplicate key violations so that only single
                # relations exist between entries and profiles.
                # This exception might be thrown if the published_by_creator
                # field is True and the provided user's profile is also included
                # in the `related_creators`
                pass

        return entry