[Answer]-Django extend own custom form

1👍

SaveCustomer.save() which maps to your Customer fails because its user instance is None and it never creates the user even when you call RegisterUser.save(), because your model in the form is set to Customer when you save a SaveCustomer form.

For the same reason, RegisterUser.save() fails because its form instance (according to step 2, a Customer), doesn’t contain a set_password().

As a solution, I don’t recommend for this particular problem using form inheritance. In my opinion, form inheritance is really useful when used on forms having the same model attribute, but as you see, when it is used on different models, it messes up.

Consider creating a unique user model (I’d recommend you inheriting from AbstractUser), or creating separate implementations of save().

👤avenet

Leave a comment