Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django 1.4: PasswordInput and Placeholder on same CharField

Django should create a CharField which is for password input and this also should be displayed on the CharField:

In HTML: <input id="password" type="password" placeholder="Password" value="">

For a password CharField i use:

class AuthForm(forms.Form):
    username  = forms.CharField(label="Your Username" )
    pw = forms.CharField( widget=forms.PasswordInput(render_value=False), label="Your Password" )

For a placeholder i would use:

pw = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'Password'}))

SOLUTION:

It seams that you don't need (render_value=False), so the solution is:

forms.CharField(widget=forms.PasswordInput(attrs={'placeholder': 'Password'}))
like image 390
Registered User Avatar asked Feb 01 '26 09:02

Registered User


1 Answers

copy-paste, according to request ;)

forms.CharField(widget=forms.PasswordInput(attrs={'placeholder': 'Password'}))
like image 192
yedpodtrzitko Avatar answered Feb 03 '26 04:02

yedpodtrzitko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!