On Tuesday, 9 December 2014 06:17:57 UTC, JAI PRAKASH SINGH wrote:
>
> 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"})
>
Make sure the last line is indented to the same level as the others.
--
DR.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/8616ab41-e72b-47b4-a82a-4c683d9cec4c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.