title: IntegrityError: UNIQUE constraint failed: user_userprofile.user_id
body: <p>I define an extra <code>UserProfile</code> to extend <code>User</code>'s attributes as</p>
  
  <pre><code>class UserProfile(models.Model):
      SEX = (
          (1, 'male'),
          (0, 'woman'),
      )
      user = models.OneToOneField(User, on_delete=models.CASCADE)
      sex = models.IntegerField(choices=SEX, default=1)
      location = models.CharField(max_length=30)
      about_me = models.TextField()
  </code></pre>
  
  <p>When I append UserProfile to existed User in Django shell</p>
  
  <pre><code>In[19]: for u in User.objects.all():
      ...:     profile = UserProfile(user=u)
      ...:     profile.save()
  </code></pre>
  
  <p>It report error:</p>
  
  <pre><code>IntegrityError: UNIQUE constraint failed: user_userprofile.user_id
  </code></pre>
  
  <p>I checked the answer <a href="https://stackoverflow.com/questions/26651688/django-integrity-error-unique-constraint-failed-user-profile-user-id">Django: Integrity error UNIQUE constraint failed: user_profile.user_id - Stack Overflow</a>, but have no ideas to solve my problem.</p>