[Answered ]-Django – RelatedObjectDoesNotExist error after post_save creation signal

1👍

It’s running the save_client_profile and complaining that the UserProfile has no client_profile attached. The create_client_profile‘s role == 1 condition isn’t met because the UserProfile’s role is not set upon creation.

The save() method of SignUpForm currently sets the role in memory but doesn’t commit it to the database, because user.save() only saves the User model, not its related UserProfile. You’ll need to do user.userprofile.save() after user.userprofile.role = self.cleaned_data.get("role") for the role to persist.

Leave a comment