views.py 文件源码

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

项目:django-powerpages 作者: Open-E-WEB 项目源码 文件源码
def page(request, path):
    """Page processing view"""
    # ensure that path starts and ends with "/"
    if not path.startswith("/"):
        path = "/" + path
    # redirect to equivalent page with ending slash
    # if path doesn't end with slash and it's not a file name:
    if not path.endswith("/") and '.' not in path.split('/')[-1]:
        return http.HttpResponsePermanentRedirect(path + "/")
    matching_pages = Page.objects.all().filter(url=path)
    try:
        page_obj = matching_pages[0]
    except IndexError:
        raise http.Http404
    page_processor = page_obj.get_page_processor()
    return page_processor.process_request(request)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号