1👍
✅
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:
def create_user_profile(sender, instance, created, **kwargs):
if created:
UserProfile.objects.get_or_create(user=instance)
signals.post_save.connect(create_user_profile, sender=User)
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 a post_save
signal. 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.
Source:stackexchange.com