如何从当前网址获取参数 [英] How to get parameters from current url
本文介绍了如何从当前网址获取参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在url中获取特定参数并在模板中使用它?
Is it possible to get an specific parameter in a url and use it in a template ?
`{{request.path}}
`{{ request.path }}
它获取了整个URL,我只需要'pk'参数即可链接到另一个页面。
It gets the whole url, i need only the 'pk' parameter, to make a link to another page.
谢谢。 / p>
Thanks.
推荐答案
我做了一些实验,发现这可能会有所帮助:
I did some experiments and find that this may help:
{{ request.resolver_match.kwargs.pk }}
更多信息,请检查此。
这篇关于如何从当前网址获取参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文