Django Error: __init__() got multiple values for keyword argument 'max_length' -


i getting error. not understand head , tail of it.

__init__() got multiple values keyword argument 'max_length'.

i adding 3 fields usercreationform django.contrib.auth.forms, email, first name , last name , want save them user object. (does first name , last name gets saved automatically).

here form trying load.

class myregistrationform(usercreationform):     #define fields     email=forms.emailfield(required=true)     first_name = forms.charfield(_('first name'), max_length=30, required=true)     last_name = forms.charfield(_('last name'), max_length=30, required=true)     helptext={'username':"* must contain alphabets , numbers",               'email':"*",               'password1':"*must contain alphabets in upper , lower case, numbers special char",               'password2': "*enter same password above, verification"}      err_messages={'invalid_username': _("username must include letters , numbers"),         'password_length': _("minimum length must 8 characters"),         'password_invalid':_("must include special character")}      def __init__(self, *args, **kwargs):         super(myregistrationform, self).__init__(*args, **kwargs)         fieldname in ['username', 'password1', 'password2','email']:             self.fields[fieldname].help_text = self.helptext[fieldname]             self.error_messages.update(self.err_messages)         class meta:         model=user         fields=('first_name','last_name','username','email','password1','password2')     #import pdb; pdb.set_trace()          def clean_username(self):         # since user.username unique, check redundant,         # sets nicer error message orm. see #13147.         username = self.cleaned_data["username"]         if not re.match(r'^\w+$',username):             raise forms.validationerror(             self.error_messages['invalid_username'],             code='invalid_username',         )         return super(myregistrationform, self).clean_username()       def clean_password2(self):         password1 = self.cleaned_data.get("password1")         if len(password1)<8:             raise forms.validationerror(             self.error_messages['password_length'],             code='password_length',         )         if not (re.search(r'[a-z]', password1) ,                  re.search(r'[a-z]', password1) ,                 re.search(r'[^a-za-z\d\s:;]',password1)):             raise forms.validationerror(             self.error_messages['password_invalid'],             code='password_invalid',         )         return super(myregistrationform, self).clean_password2()      def clean_email(self):             email = self.cleaned_data["email"]             try:                 user = user.objects.get(email=email)                 print user.email                 print user.username                 raise forms.validationerror("this email address exists. did forget password?")             except user.doesnotexist:                 return email      def save(self, commit=true):             user = super(myregistrationform, self).save(commit=false)             user.email=self.cleaned_data["email"]             if commit:                 user.save()             return user 

i have read article did not in situation.

what daniel suggested above should work.

first_name = forms.charfield(label=_('first name'), max_length=30, required=true) 

you dont need save first name , last_name explicitly. taken care save function have above. unless want cleaning yourselves.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -