  
  
  @python_2_unicode_compatible
  class SelfRef(models.Model):
      selfref = models.ForeignKey('self', null=True, blank=True,
                                  related_name='+')
  
      def __str__(self):
          # This method intentionally doesn't work for all cases - part
          # of the test for ticket #20278
          return SelfRef.objects.get(selfref=self).pk
 
</s> remove     parent = models.ForeignKey('self', null=True, blank=True)
 </s> add     parent = models.ForeignKey('self', models.SET_NULL, null=True, blank=True) </s> remove     section = models.ForeignKey(Section, null=True, blank=True)
    sub_section = models.ForeignKey(Section, null=True, blank=True, on_delete=models.SET_NULL, related_name='+')
 </s> add     section = models.ForeignKey(Section, models.CASCADE, null=True, blank=True)
    sub_section = models.ForeignKey(Section, models.SET_NULL, null=True, blank=True, related_name='+') </s> remove     holder = models.ForeignKey(Holder3)
 </s> add     holder = models.ForeignKey(Holder3, models.CASCADE) </s> remove     chapter = models.ForeignKey(Chapter, on_delete=models.PROTECT)
 </s> add     chapter = models.ForeignKey(Chapter, models.PROTECT) </s> remove     user = models.OneToOneField(User, primary_key=True)
 </s> add     user = models.OneToOneField(User, models.CASCADE, primary_key=True)
    selfref = models.ForeignKey(
        'self',
        models.SET_NULL,
        null=True, blank=True,
        related_name='+',
    )
  
  
  @python_2_unicode_compatible
  class SelfRef(models.Model):
    selfref = models.ForeignKey(
        'self',
        models.SET_NULL,
        null=True, blank=True,
        related_name='+',
    )
    selfref = models.ForeignKey(
        'self',
        models.SET_NULL,
        null=True, blank=True,
        related_name='+',
    )
  
      def __str__(self):
          # This method intentionally doesn't work for all cases - part
          # of the test for ticket #20278
          return SelfRef.objects.get(selfref=self).pk
keep keep keep keep replace replace keep keep keep keep keep
 Fixed #21127 -- Started deprecation toward requiring on_delete for ForeignKey/OneToOneField 
tests/basic/models.py