mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Fixed #21127 -- Started deprecation toward requiring on_delete for ForeignKey/OneToOneField
This commit is contained in:
parent
87d55081ea
commit
c2e70f0265
176 changed files with 1525 additions and 1008 deletions
|
@ -16,7 +16,11 @@ In this example, a ``Place`` optionally can be a ``Restaurant``::
|
|||
return "%s the place" % self.name
|
||||
|
||||
class Restaurant(models.Model):
|
||||
place = models.OneToOneField(Place, primary_key=True)
|
||||
place = models.OneToOneField(
|
||||
Place,
|
||||
on_delete=models.CASCADE,
|
||||
primary_key=True,
|
||||
)
|
||||
serves_hot_dogs = models.BooleanField(default=False)
|
||||
serves_pizza = models.BooleanField(default=False)
|
||||
|
||||
|
@ -24,7 +28,7 @@ In this example, a ``Place`` optionally can be a ``Restaurant``::
|
|||
return "%s the restaurant" % self.place.name
|
||||
|
||||
class Waiter(models.Model):
|
||||
restaurant = models.ForeignKey(Restaurant)
|
||||
restaurant = models.ForeignKey(Restaurant, on_delete=models.CASCADE)
|
||||
name = models.CharField(max_length=50)
|
||||
|
||||
def __str__(self): # __unicode__ on Python 2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue