router.py 文件源码

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

项目:nhsuk-content-store 作者: nhsuk 项目源码 文件源码
def get_object(self):
        """
        Returns the page with id == the one passed in for a particular revision.

        The revision can be selected by using the query param `revision-id` which defaults to the latest one.
        """
        obj = super().get_object()

        revision_id = self.request.query_params.get('revision-id')
        if revision_id:
            revision = get_object_or_404(obj.revisions, id=revision_id)
        else:
            revision = obj.revisions.order_by('-created_at').first()

        # in case of no revisions, return the object (edge case)
        if not revision:
            return obj

        base = revision.as_page_object()
        return base.specific
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号