2014-07-10 35 views
0

返回Django模板字符串我想削减多数民众赞成由request.post在模板中返回的字符串:削减多数民众赞成由request.post

如:

我访问URL /foo/bar/long/现在

{% if request.path[:8] == '/foo/bar' %}...{endif} 

应该是真的。

回答

3

使用内置模板过滤器称为slice

{% if request.path|slice:':8' == '/foo/bar' %}...{endif} 
+0

谢谢你,也为参考! –

相关问题