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.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.