2024-04-30 02:13:55 发布
网友
我使用的代码是:
<div class="stream {% if streams.online %}online{% else %}offline{% endif %}">
似乎有点多余。我想运行这个代码
<div class="stream {{ 'online' if stream.online else 'offline' }}">
但不幸的是,这不起作用。有没有一种更短、更整洁的方法来做我想做的事?
你不能用^{} built-in template filter吗?
就像在里面一样
<div class="stream {{ stream.online|yesno:"online,offline" }}">
你不能用^{} built-in template filter 吗?
就像在里面一样
相关问题 更多 >
编程相关推荐