mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +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
|
@ -56,7 +56,7 @@ class Post(models.Model):
|
|||
|
||||
@python_2_unicode_compatible
|
||||
class Attachment(models.Model):
|
||||
post = models.ForeignKey(Post, related_name='attached_%(class)s_set')
|
||||
post = models.ForeignKey(Post, models.CASCADE, related_name='attached_%(class)s_set')
|
||||
content = models.TextField()
|
||||
|
||||
class Meta:
|
||||
|
@ -107,7 +107,7 @@ class Rating(models.Model):
|
|||
class Restaurant(Place, Rating):
|
||||
serves_hot_dogs = models.BooleanField(default=False)
|
||||
serves_pizza = models.BooleanField(default=False)
|
||||
chef = models.ForeignKey(Chef, null=True, blank=True)
|
||||
chef = models.ForeignKey(Chef, models.SET_NULL, null=True, blank=True)
|
||||
|
||||
class Meta(Rating.Meta):
|
||||
db_table = 'my_restaurant'
|
||||
|
@ -135,8 +135,8 @@ class Supplier(Place):
|
|||
@python_2_unicode_compatible
|
||||
class ParkingLot(Place):
|
||||
# An explicit link to the parent (we can control the attribute name).
|
||||
parent = models.OneToOneField(Place, primary_key=True, parent_link=True)
|
||||
main_site = models.ForeignKey(Place, related_name='lot')
|
||||
parent = models.OneToOneField(Place, models.CASCADE, primary_key=True, parent_link=True)
|
||||
main_site = models.ForeignKey(Place, models.CASCADE, related_name='lot')
|
||||
|
||||
def __str__(self):
|
||||
return "%s the parking lot" % self.name
|
||||
|
@ -156,7 +156,7 @@ class Title(models.Model):
|
|||
|
||||
|
||||
class NamedURL(models.Model):
|
||||
title = models.ForeignKey(Title, related_name='attached_%(app_label)s_%(class)s_set')
|
||||
title = models.ForeignKey(Title, models.CASCADE, related_name='attached_%(app_label)s_%(class)s_set')
|
||||
url = models.URLField()
|
||||
|
||||
class Meta:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue