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