api.py 文件源码

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

项目:c3nav 作者: c3nav 项目源码 文件源码
def retrieve(self, request, key=None, *args, **kwargs):
        show_redirects = 'show_redirects' in request.GET
        detailed = 'detailed' in request.GET
        geometry = 'geometry' in request.GET

        location = self.get_object()

        if location is None:
            raise NotFound

        if isinstance(location, LocationRedirect):
            if not show_redirects:
                return redirect('../' + str(location.target.slug))  # todo: why does redirect/reverse not work here?

        return Response(location.serialize(include_type=True, detailed=detailed,
                                           geometry=geometry, simple_geometry=True))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号