I have a user profile I’ve created that needs to have some parameters passed to it to avoid IntegrityError‘s, such as non-nullable fields. I wrote my creation hook as described here on the bottom of the page, but when I call create_user, I get integrity errors since the create_user is trying to save the user I just created with the uninitialized profile. How can I get around this?
I have a user profile I’ve created that needs to have some parameters passed
Share
There’s no detail at the provided link on how to automatically create a user profile, so I’m not sure how you’ve actually set that up. However, this is the typical way:
It sounds like your problem is that
UserProfile(or your equivalent model) has additional fields that cannot be null, and as such, you want to provide values for those fields. However, that’s simply not possible using apost_savesignal. Generally all non-char fields on a profile are nullable or provide sensible defaults, so then, you can at least create the object without specific info. Through your interface, you can enforce that users fill out their profiles, but it’s not prudent to enforce that at the database level.