1👍
✅
You never pass the POST data to the form: so it remains unbound, and does not go through validation. You need to do userDataForm = UserDataForm(request.POST, instance=userProfile)
What’s worse, you have explicitly defined your forms’ __init__
methods so that they don’t even accept any argument other than instance – so it’s impossible ever to populate then with data. In addition, they actually swallow the instance
argument and don’t pass it up to the superclass, so it is effectively ignored. You should define them like this:
def __init__(self, *args, **kwargs):
instance = kwargs.get('instance')
super(UserDataForm, self).__init__(*args, **kwargs)
0👍
You need to instantiate userForm in the view by passing request.POST to it directly – you’re passing a user model instance.
Try: userForm = UserForm(request.POST)
Source:stackexchange.com