title: Django: Integrity error UNIQUE constraint failed: user_profile.user_id
body: <p>When I am trying to edit a profile to add info to a UserProfile model, I am getting this strange error:</p>
  
  <pre><code>IntegrityError at /profiles/edit/
  UNIQUE constraint failed: user_profile.user_id
  </code></pre>
  
  <p>What is wrong here,</p>
  
  <p>model:</p>
  
  <pre><code>class UserProfile(models.Model):
  
      user = models.OneToOneField(User)
      bio = models.TextField(blank=True)
      phone= models.CharField(max_length=10, blank=True)
      address = models.CharField(max_length=1024)
      age = models.PositiveIntegerField(blank=True,null=True)
      gender = models.IntegerField(choices=GENDER_CHOICES, default=1)
  </code></pre>
  
  <p>form:</p>
  
  <pre><code>class UserProfileForm(forms.ModelForm):
  
      class Meta:
          model = UserProfile
          fields = ('phone','age','gender','address','bio')
  </code></pre>
  
  <p>view:</p>
  
  <pre><code>def edit_profile(request):
  
      if request.method == 'POST':
          form = UserProfileForm(request.POST)
          print request.POST
          if form.is_valid():
  
              new_profile = UserProfile(
                              user = request.user,
                              bio = request.POST['bio'],
                              address = request.POST['address'],
                              age = request.POST['age']
                              )
  
              new_profile.save()
  
              return HttpResponseRedirect(reverse('user_public_profile', args=(request.user.username,)))
          return render(request,'users/edit_profile.html', {'form': form})
  
      else:
          form = UserProfileForm()
          return render(request,'users/edit_profile.html',
                            {'form': form})
  </code></pre>