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
评论列表
文章目录