serializers.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:gennotes 作者: madprime 项目源码 文件源码
def _check_current_version(self, instance):
        """
        Check that the edited_version parameter matches the current version.

        If different, it indicates a probably "edit conflict": the submitted
        edit is being made to a stale version of the model.
        """
        edited_version = self.context['request'].data['edited_version']
        current_version = reversion.get_for_date(
            instance, timezone.now()).id
        if not current_version == edited_version:
            raise serializers.ValidationError(detail={
                'detail':
                    'Edit conflict error! The current version for this object '
                    'does not match the reported version being edited.',
                'current_version': current_version,
                'submitted_data': self.context['request'].data,
            })
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号