from django.contrib.auth.models import User
from django import forms

# Create your forms here.

class UserForm(forms.ModelForm):
    password = forms.CharField(widget=forms.PasswordInput)

    class Meta:
        model = User
        fields = ['username', 'email', 'password']

from django.contrib.auth.models import User
from django import forms

# Create your forms here.

class BootstrapForm(forms.ModelForm):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for visible in self.visible_fields():
            visible.field.widget.attrs['class'] = 'form-control'
            visible.field.widget.attrs['placeholder'] = 'Please enter value'


class UserForm(BootstrapForm):
    password = forms.CharField(widget=forms.PasswordInput)

    class Meta:
        model = User
        fields = ['username', 'email', 'password']

Add BootstrapForm to beautify form_template
Add BootstrapForm to beautify form_template

  from django.contrib.auth.models import User
  from django import forms
  
  # Create your forms here.
  
- class UserForm(forms.ModelForm):
+ class BootstrapForm(forms.ModelForm):
+ 
+     def __init__(self, *args, **kwargs):
+         super().__init__(*args, **kwargs)
+         for visible in self.visible_fields():
+             visible.field.widget.attrs['class'] = 'form-control'
+             visible.field.widget.attrs['placeholder'] = 'Please enter value'
+ 
+ 
+ class UserForm(BootstrapForm):
      password = forms.CharField(widget=forms.PasswordInput)
  
      class Meta:
          model = User
          fields = ['username', 'email', 'password']
  
Add BootstrapForm to beautify form_template
## Code Before:
from django.contrib.auth.models import User
from django import forms

# Create your forms here.

class UserForm(forms.ModelForm):
    password = forms.CharField(widget=forms.PasswordInput)

    class Meta:
        model = User
        fields = ['username', 'email', 'password']

## Instruction:
Add BootstrapForm to beautify form_template
## Code After:
from django.contrib.auth.models import User
from django import forms

# Create your forms here.

class BootstrapForm(forms.ModelForm):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for visible in self.visible_fields():
            visible.field.widget.attrs['class'] = 'form-control'
            visible.field.widget.attrs['placeholder'] = 'Please enter value'


class UserForm(BootstrapForm):
    password = forms.CharField(widget=forms.PasswordInput)

    class Meta:
        model = User
        fields = ['username', 'email', 'password']
