Skip to content

Commit c760792

Browse files
committed
Added proxy ForeignKey and OneToOneField classes which set the now required on_delete parameter on the fields to the legacy value.
- Legacy-Id: 14660
1 parent f5cf9a2 commit c760792

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

ietf/utils/models.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,14 @@ class VersionInfo(models.Model):
1515
used = models.BooleanField(default=True)
1616
class Meta:
1717
verbose_name_plural = 'VersionInfo'
18+
19+
class ForeignKey(models.ForeignKey):
20+
"A local ForeignKey proxy which provides the on_delete value required under Django 2.0."
21+
def __init__(self, to, on_delete=models.CASCADE, **kwargs):
22+
return super(ForeignKey, self).__init__(to, on_delete=on_delete, **kwargs)
23+
24+
class OneToOneField(models.OneToOneField):
25+
"A local OneToOneField proxy which provides the on_delete value required under Django 2.0."
26+
def __init__(self, to, on_delete=models.CASCADE, **kwargs):
27+
return super(OneToOneField, self).__init__(to, on_delete=on_delete, **kwargs)
1828

0 commit comments

Comments
 (0)