title: FOREIGN KEY constraint failed in signals
body: <p>I  tried to insert data into the table Account, but I keep getting this error message.
  I delete all my migrations and make migrations again but I keep getting this error.</p>
  
  <p>Here is my models.</p>
  
  <pre><code>
  class Student(models.Model):
      user                = models.OneToOneField(Account, on_delete=models.CASCADE)
      name                = models.CharField(max_length=50, null=True, blank=True)
      phone               = models.CharField(max_length=15, blank=True, null=True)
      gender              = models.CharField(max_length=1, choices=GENDER_CHOICES, blank=True, null=True)
      section             = models.ForeignKey(Section, on_delete=models.CASCADE, default=1)
      dept                = models.ForeignKey(Dept, on_delete=models.CASCADE, blank=True, null=True)
      batch               = models.CharField(max_length=15, null=True, blank=True)
      USN                 = models.CharField(primary_key='True', max_length=100)
      DOB                 = models.DateField(default='1998-01-01')
      profile_image       = models.ImageField(upload_to='student/profile_images/%Y/%m/%d/', blank=True, null=True)
      address             = models.CharField(max_length=300, null=True, blank=True)
      nationality         = models.CharField(max_length=100, null=True, blank=True)
  
      guardian_name       = models.CharField(max_length=200, null=True, blank=True)
      guardian_number     = models.CharField(max_length=15, null=True, blank=True)
      guardian_address    = models.CharField(max_length=300, null=True, blank=True)
      blood_group         = models.CharField(max_length=3, null=True, blank=True)
  
      exam_name           = models.CharField(max_length=300, null=True, blank=True)
      background          = models.CharField(max_length=300, null=True, blank=True)
      passing_year        = models.CharField(max_length=8, null=True, blank=True)
      score               = models.CharField(max_length=10, null=True, blank=True)
      school_name         = models.CharField(max_length=300, null=True, blank=True)
      country             = models.CharField(max_length=100, null=True, blank=True)
      certificate         = models.FileField(upload_to='certificates/%Y/%m/%d/', null=True, blank=True)
  
  </code></pre>
  
  <p>Here is Account model.</p>
  
  <pre><code>
  class Account(AbstractBaseUser, PermissionsMixin):
      unid                    = models.CharField(max_length=20, unique=True, null=True, blank=True)
      email                   = models.EmailField(verbose_name="email", max_length=60, unique=True)
      username                = models.CharField(max_length=30, unique=True)
      is_admin                = models.BooleanField(default=False)
      is_active               = models.BooleanField(default=True)
      is_staff                = models.BooleanField(default=False)
      is_superuser            = models.BooleanField(default=False)
      is_student              = models.BooleanField(default=False)
      is_teacher              = models.BooleanField(default=False)
      group                   = models.ForeignKey(Group, on_delete=models.CASCADE, null=True, blank=True)
      user_permissions        = models.ManyToManyField(
                                                  Permission,
                                                  verbose_name=_('user permissions'),
                                                  blank=True,
                                                  null=True,
                                                  help_text=_('Specific permissions for this user.'),
                                                  related_name="user_set",
                                                  related_query_name="user",
                                              )
      date_joined             = models.DateTimeField(verbose_name='date joined', auto_now_add=True)
      last_login              = models.DateTimeField(verbose_name='last login', auto_now=True)
      registered              = models.BooleanField(default=False)
  </code></pre>
  
  <p>so what I did is that when I create account if the is_student is True I create a signals that going to create student model for that account instance automatically.</p>
  
  <p>here is the signals</p>
  
  <pre><code>def create_student_or_teacher(sender, created, instance, **kwargs):
      if created:
          if instance.is_student:
              Student.objects.create(
                  user=instance,
                  USN=instance.unid,
              )
          elif instance.is_teacher:
              Teacher.objects.create(
                  user=instance,
                  id=instance.unid,
              )
  
  </code></pre>
  
  <p>So when I create the account for student the tracker will highlight in the signals <code>Student.objects.create(...)</code> 
  If you have any idea I hope it would help me.</p>
  
  <p>UPDATED:</p>
  
  <p>When I'm creating teacher it is working find. 
  here is the teacher model</p>
  
  <pre><code>class Teacher(models.Model):
      name                = models.CharField(max_length=50, null=True, blank=True)
      phone               = models.CharField(max_length=15, blank=True, null=True)
      gender              = models.CharField(max_length=1, choices=GENDER_CHOICES, blank=True)
      salary              = models.IntegerField(default=1)
      school              = models.ForeignKey(School, blank=True, null=True, on_delete=models.CASCADE)
      section             = models.ForeignKey(Section, blank=True, null=True, on_delete=models.CASCADE)
      user                = models.OneToOneField(Account, on_delete=models.CASCADE, null=True)
      id                  = models.CharField(primary_key=True, max_length=100)
      dept                = models.ForeignKey(Dept, on_delete=models.CASCADE, blank=True, null=True)
      DOB                 = models.DateField(default='1980-01-01')
      profile_image       = models.ImageField(upload_to='teacher/profile_images/%Y/%m/%d/', blank=True, null=True)
      nationality         = models.CharField(max_length=300, null=True, blank=True)
      address             = models.CharField(max_length=300, null=True, blank=True)
  </code></pre>