我试图将dynamic id属性设置为HTML中的<body>
标记。在
像这样-<body id="{{ django_view_name }}>"
我希望id
属性具有页面名称,例如主页id="home"
和博客页面{
我不想使用Javascript或Jquery。在
我创建了一个main.html
模板,然后我inheriting
作为其他模板中的主模板,比如index.html
模板。在
main.html
标记中的代码如下-
<div class="content-wrapper" id="content">
<%include file="${static.get_template_path('header.html')}" args="online_help_token=online_help_token" />
${self.body()}
</div>
然后在index.html
模板上,我是inheriting
这样-
更新:必需的附加信息
如何计算${ request.resolver_match.url_name }
的值。例如,如果id="${ request.resolver_match.url_name }"
的计算结果是id="home"
,那么我想做如下操作-
%if ${ request.resolver_match.url_name }=root:
<div class="container">
else:
something_else
我该怎么做?任何帮助都是非常感谢的。在
试试这个
这将根据您在
urls.py
url中定义的url名称生成id更新: 在编辑问题之后,我看到你使用了mako模板
所以你需要
^{pr2}$相关问题 更多 >
编程相关推荐