Issue
First, I will try to solve this problem using native HTML and jquery, but I want to solve this problem in Django form without any script.
I will try this source code.
My expected output is put this same example in the above link to Django form.
Solution
class CustomerLoginFrom(ModelForm):
class Meta:
model = UserLogin
fields = ['user_name','password']
labels = {
"user_name": "*Username",
"password": "*Password"
}
widgets = {
"user_name": TextInput(attrs={'placeholder':'ex:test','autocomplete': 'off'}),
"password": PasswordInput(attrs={'placeholder':'********','autocomplete': 'off','data-toggle': 'password'}),
}
<input type="password" id="password" name="password" class="form-control" data-toggle="password">
Django password field to add HTML attributes directly to Django form attrs, it works for me.
Answered By - muthu
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.