Django中是否有过滤器显示星号(*)而不是文本 [英] Is there any filter in Django to display asterisk(*) instead of text
本文介绍了Django中是否有过滤器显示星号(*)而不是文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
mytext ='raja '
{{mytext | password}}
应该显示 ****
我们如何做到这一点。 plz help
解决方案
简单。这样做:
{%for my text%} * {%endfor%}
那么说,我可以问你在哪里显示密码?通常密码不会显示在屏幕上。如果要以表单形式显示,您可以使用 PasswordInput
小部件。
由于@Ars说透露密码的长度是一个坏主意。您可能想要显示一个随机数的星号。
I am eager to know whether any filter is available for displaying all the text as * like this
mytext = 'raja'
{{ mytext|password }}
should show ****
How can we do this. plz help
解决方案
Easy. Do this:
{% for char in mytext %}*{% endfor %}
That said, can I ask you where you are displaying the password? Usually passwords are not displayed on screen. If you want to display it in a form you can use a PasswordInput
widget.
As @Ars said it is a bad idea to reveal the length of the password. You might want to display a random number of asterisks instead.
这篇关于Django中是否有过滤器显示星号(*)而不是文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文