Django中是否有任何过滤器显示星号(*)而不是文本 [英] Is there any filter in Django to display asterisks (*) instead of text

查看:118
本文介绍了Django中是否有任何过滤器显示星号(*)而不是文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很想知道是否有任何过滤器可用于将所有文本显示为*这样的

I am eager to know whether any filter is available for displaying all the text as * like this

mytext = 'raja'

{{mytext | password}} 应该显示 ****

我们该怎么做?

推荐答案

简单。为此:

{% for char in mytext %}*{% endfor %}

那我可以问一下您在哪里显示密码吗?通常,密码不会显示在屏幕上。如果要以表格形式显示它,可以使用 PasswordInput 小部件。

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.

正如@Ars所说,公开密码的长度是一个坏主意。您可能要显示随机数量的星号。

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屋!

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