IF在Django模板系统中 [英] IF in the Django template system

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

问题描述

如何做到这一点:

{% if thestring %}

    {% if thestring.find("1") >= 0 %}

    {% endif %}

{% endif %}

我假设我需要构建模板过滤器?这个工作吗?

I am assuming I need to build a template filter? Will that work?

推荐答案

你不需要来构建一个自定义过滤器,工作 - 编码方式

You don't need to build a custom filter, though one would work -- the alternative of coding

{% if thestring %}

    {% if "1" in thestring %}

    {% endif %}

{% endif %}

也会很好。

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

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