1👍
✅
Try it:
self.fields['password1'] = forms.CharField(label=_("Password"),
widget=forms.PasswordInput, required = False)
self.fields['password2'] = forms.CharField(label=_("Password confirmation"),
widget=forms.PasswordInput, required = False,
help_text = _("Enter the same password as above, for verification."))
1👍
This is a common error: you have overwritten the signature of the form’s __init__
method, so that the first argument is current_user
. So when in your POST block you instantiate the form with UserProfileForm(request.POST, instance=user_profile)
, the data dictionary is taken for the current_user parameter and the actual data parameter is empty. Because it’s empty, the form is not bound, so there are no errors.
The best way to override a form’s __init__
is to take any new parameters from args
or kwargs
:
def __init__(self, *args, **kwargs):
current_user = kwargs.pop('current_user')
super(UserProfileForm, self).__init__(*args, **kwargs)
etc.
- [Answered ]-Use php while running mod_wsgi-express with django
- [Answered ]-Django : join without related object
- [Answered ]-Django: Slug in Vietnamese working not correctly
- [Answered ]-Baffled by python __str__ method and unicode behaviour
- [Answered ]-Django REST Framework user registration Validation confusion
0👍
Should it not just be {‘form’:form, } in the view def.
Then in the template use {{ form.as_p }}
- [Answered ]-Optimise two SQL queries and a list comprehension
- [Answered ]-TastyPie authentication for pure javascript site
- [Answered ]-How to use Django with Angular-cli@webpack
- [Answered ]-How do I connect a django rest framework json query result to dgrid/OnDemandGrid
Source:stackexchange.com