How to use more than one widget in a Django field?

I have a specific field in the form that should have a user attribute. And we call the password field. I currently have:

login_password = forms.CharField(label=(u'password'))

But I need both:

widget=forms.TextInput(attrs={'placeholder': 'password'})
widget=forms.PasswordInput(render_value=False)

How can I do this so that the field uses these two widgets? I read about MultiWidget, but I'm not sure if this is what I need to use or how to use it exactly.

+3
source share
1 answer

PasswordInputalso accepts attrs.

login_password = forms.CharField(label=u'password', widget=forms.PasswordInput(render_value=False, attrs={'placeholder': 'password'}))
+4
source

All Articles