I am trying to validate whether password1, password2 are matching not using object level validation because it is executed after all field level validations, but validate_field only accepts one value. How can I implement the following in rest framework?
def validate_password2(self, data):
print 'validating...'
password1, password2 = data['password1'], data['password2']
if password1 and password2 and password1 != password2:
raise serializers.ValidationError('The two passwords do not match.')
return password2
And when errors occur, the data in the form are cleared. How can I retain the input data even when the errors occur like django form.fields?