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
|
@ -10,7 +10,7 @@ from django.utils.encoding import python_2_unicode_compatible
|
|||
@python_2_unicode_compatible
|
||||
class Review(models.Model):
|
||||
source = models.CharField(max_length=100)
|
||||
content_type = models.ForeignKey(ContentType)
|
||||
content_type = models.ForeignKey(ContentType, models.CASCADE)
|
||||
object_id = models.PositiveIntegerField()
|
||||
content_object = GenericForeignKey()
|
||||
|
||||
|
@ -58,7 +58,7 @@ class Book(models.Model):
|
|||
title = models.CharField(max_length=100)
|
||||
published = models.DateField()
|
||||
authors = models.ManyToManyField(Person)
|
||||
editor = models.ForeignKey(Person, null=True, related_name='edited')
|
||||
editor = models.ForeignKey(Person, models.SET_NULL, null=True, related_name='edited')
|
||||
reviews = GenericRelation(Review)
|
||||
pages = models.IntegerField(default=100)
|
||||
|
||||
|
@ -72,7 +72,7 @@ class Book(models.Model):
|
|||
@python_2_unicode_compatible
|
||||
class Pet(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
owner = models.ForeignKey(Person)
|
||||
owner = models.ForeignKey(Person, models.CASCADE)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
@ -82,7 +82,7 @@ class Pet(models.Model):
|
|||
|
||||
|
||||
class UserProfile(models.Model):
|
||||
user = models.OneToOneField(User, null=True)
|
||||
user = models.OneToOneField(User, models.SET_NULL, null=True)
|
||||
flavor = models.CharField(max_length=100)
|
||||
|
||||
class Meta:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue