hello all,
I am trying to make a registration form using User model so i am using ModelForm
as I am using bootstrap template i need to add some atribute like class placeholder
so i am using widget, am facing a problem , i searchd a lot but unable to find the solution
please help
my code is under
####################################################################
error :- name 'self' is not defined
on borwser
######################################################################3
forms.py
class RegistrationForm(ModelForm):
class Meta:
model = User
fields = [ 'username', 'password', 'email' ]
def __init__(self, *args, **kwargs):
super(RegistrationForm, self).__init__(*args, **kwargs)
self.fields['username'].widget = forms.TextInput(attrs={"placeholder" : "First Name",
"name" : "first_name"})
self.fields['email'].widget = forms.TextInput(attrs={"placeholder" : "Email Address",
"name" : "email"})
self.fields['password'].widget = forms.PasswordInput(attrs={
"placeholder" : "Password", "name" : "password", "class" : "form-control input-sm"})