title: How to debug "django.db.utils.IntegrityError: UNIQUE constraint failed"?
body: <p>I'm unable to debug this:</p>
  
  <blockquote>
    <p>django.db.utils.IntegrityError: UNIQUE constraint failed: post_employee.employee_id</p>
  </blockquote>
  
  <p>I'm saving value through my inbuilt admin then it's working fine, but when I am editing those values then it's raising integrityError. Here is my code:</p>
  
  <p>models.py </p>
  
  <pre><code>from django.db import models
  from django.db.models.signals import post_save
  # Create your models here.
  class Person(models.Model):
      name = models.CharField(max_length=100)
      gender = models.CharField(max_length=10)
  
      def __str__(self):
          return (self.name)
  
  class Employee(models.Model):
      employee = models.OneToOneField(Person,on_delete=models.CASCADE)
      emp_no = models.CharField(max_length=100)
      desgnation = models.CharField(max_length=100)
  
      def __str__(self):
          return str(self.employee)
  
  
  
  def create_profile(sender,**kwargs):
      if kwargs:
          Employee.objects.create(employee = kwargs['instance'])
  post_save.connect(create_profile,sender=Person)
  </code></pre>
  
  <p>Errors </p>
  
  <pre><code>IntegrityError at /admin/post/person/1/change/
  UNIQUE constraint failed: post_employee.employee_id
  Request Method: POST
  Request URL:    http://localhost:8000/admin/post/person/1/change/
  Django Version: 2.0.5
  Exception Type: IntegrityError
  Exception Value:    
  UNIQUE constraint failed: post_employee.employee_id
  </code></pre>
  
  <p>In database i am seeing  <code>employee_id - integer - employee_id NOT NULL UNIQUE</code></p>
  
  <p>Is this IntegerityError coming for this UNIQUE, then how to correct it? I want to remove this integrity error.</p>