          return user
  
  
  class CustomUserWithFK(AbstractBaseUser):
      username = models.ForeignKey(Email, related_name='primary')
      email = models.ForeignKey(Email, to_field='email', related_name='secondary')
      group = models.ForeignKey(Group)
  
      custom_objects = CustomUserWithFKManager()
  
      USERNAME_FIELD = 'username'
      REQUIRED_FIELDS = ['email', 'group']
 
</s> remove     group = models.ForeignKey(Group)
 </s> add     group = models.ForeignKey(Group, models.CASCADE) </s> remove     music = models.ForeignKey(Musician)
    group = models.ForeignKey(Group)
 </s> add     music = models.ForeignKey(Musician, models.CASCADE)
    group = models.ForeignKey(Group, models.CASCADE) </s> remove             person = models.ForeignKey(Person)
            group = models.ForeignKey(Group)
 </s> add             person = models.ForeignKey(Person, models.CASCADE)
            group = models.ForeignKey(Group, models.CASCADE) </s> remove     user = models.ForeignKey(User, to_field="username")
 </s> add     user = models.ForeignKey(User, models.CASCADE, to_field="username") </s> remove         person = models.ForeignKey(Person)
        group = models.ForeignKey(Group)
 </s> add         person = models.ForeignKey(Person, on_delete=models.CASCADE)
        group = models.ForeignKey(Group, on_delete=models.CASCADE)
    username = models.ForeignKey(Email, models.CASCADE, related_name='primary')
    email = models.ForeignKey(Email, models.CASCADE, to_field='email', related_name='secondary')
    group = models.ForeignKey(Group, models.CASCADE)
          return user
  
  
  class CustomUserWithFK(AbstractBaseUser):
    username = models.ForeignKey(Email, models.CASCADE, related_name='primary')
    email = models.ForeignKey(Email, models.CASCADE, to_field='email', related_name='secondary')
    group = models.ForeignKey(Group, models.CASCADE)
    username = models.ForeignKey(Email, models.CASCADE, related_name='primary')
    email = models.ForeignKey(Email, models.CASCADE, to_field='email', related_name='secondary')
    group = models.ForeignKey(Group, models.CASCADE)
    username = models.ForeignKey(Email, models.CASCADE, related_name='primary')
    email = models.ForeignKey(Email, models.CASCADE, to_field='email', related_name='secondary')
    group = models.ForeignKey(Group, models.CASCADE)
  
      custom_objects = CustomUserWithFKManager()
  
      USERNAME_FIELD = 'username'
      REQUIRED_FIELDS = ['email', 'group']
keep keep keep keep replace replace replace keep keep keep keep keep
 Fixed #21127 -- Started deprecation toward requiring on_delete for ForeignKey/OneToOneField 
tests/auth_tests/models/with_foreign_key.py