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
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.
is this really a password? Then it seems like a bad idea -- do you want to reveal that the password is 4 characters long? Just print 4 (or 5 or whatever) asterisks straight in the template always.
Otherwise, I wouldn't bother with a filter. Simply pass in a string of asterisks through the context:
mytext = 'raja'
ctx = Context({'mytext': '*' * len(mytext)})
t = Template('password: {{ mytext }}')
s = t.render(ctx)