阅读模板中的路径 [英] Reading path in templates

查看:104
本文介绍了阅读模板中的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法读取当前页面的路径?例如,我在www.example.com/foo/bar/ - 我想读'/ foo / bar /'。我必须在模板文件中执行此操作,而不修改视图,并且我有太多的视图文件来编辑每个视图。



干杯。

解决方案

使用请求上下文处理器启用,您可以使用 {{request.path}} 来获取所有的URL路径的模板。


is there any way to read the path to the current page? For example, I am at www.example.com/foo/bar/ - and I want to read '/foo/bar/'. I have to do this in the template file without modifying views, and I have too many view files to edit each one.

Cheers.

解决方案

With the request context processor enabled, you can use {{ request.path }} to get the url path in all of your templates.

这篇关于阅读模板中的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆