  
  
  class NonAutoPKBook(models.Model):
      rand_pk = models.IntegerField(primary_key=True, editable=False)
      author = models.ForeignKey(Author)
      title = models.CharField(max_length=50)
  
      def save(self, *args, **kwargs):
          while not self.rand_pk:
              test_pk = random.randint(1, 99999)
 
</s> remove     author = models.ForeignKey(Author)
 </s> add     author = models.ForeignKey(Author, models.CASCADE) </s> remove     author = models.ForeignKey(Author)
 </s> add     author = models.ForeignKey(Author, models.CASCADE) </s> remove     author = models.ForeignKey(Author, unique=True)
 </s> add     author = models.ForeignKey(Author, models.CASCADE, unique=True) </s> remove     parent = models.ForeignKey(AutoPKParent)
 </s> add     parent = models.ForeignKey(AutoPKParent, models.CASCADE) </s> remove     author = models.ForeignKey(Author)
    book = models.ForeignKey(Book)
 </s> add     author = models.ForeignKey(Author, models.CASCADE)
    book = models.ForeignKey(Book, models.CASCADE)
    author = models.ForeignKey(Author, models.CASCADE)
  
  
  class NonAutoPKBook(models.Model):
      rand_pk = models.IntegerField(primary_key=True, editable=False)
    author = models.ForeignKey(Author, models.CASCADE)
      title = models.CharField(max_length=50)
  
      def save(self, *args, **kwargs):
          while not self.rand_pk:
              test_pk = random.randint(1, 99999)
keep keep keep keep replace keep keep keep keep keep
 Fixed #21127 -- Started deprecation toward requiring on_delete for ForeignKey/OneToOneField 
tests/admin_inlines/models.py