post_save user signal that creates user profile is being called twice causing duplicate key value violates unique constraint, only in admin console
问题 I have a model called UserProfile which stores additional data about a django user. This model has a OneToOneField to django.contrib.auth.models.User I also have a post save signal on a User object that is fired on initial insert of a User which creates a UserProfile object linked to that User: def create_user_profile(sender, instance, created, **kwargs): if created: UserProfile.objects.create(user=instance) post_save.connect(create_user_profile, sender=User) User objects can be created via