mirror of
https://github.com/django/django.git
synced 2025-07-24 13:44:32 +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
|
@ -34,7 +34,7 @@ class AuthorWithEvenLongerName(models.Model):
|
|||
|
||||
|
||||
class Book(models.Model):
|
||||
author = models.ForeignKey(Author)
|
||||
author = models.ForeignKey(Author, models.CASCADE)
|
||||
title = models.CharField(max_length=100, db_index=True)
|
||||
pub_date = models.DateTimeField()
|
||||
# tags = models.ManyToManyField("Tag", related_name="books")
|
||||
|
@ -44,7 +44,7 @@ class Book(models.Model):
|
|||
|
||||
|
||||
class BookWeak(models.Model):
|
||||
author = models.ForeignKey(Author, db_constraint=False)
|
||||
author = models.ForeignKey(Author, models.CASCADE, db_constraint=False)
|
||||
title = models.CharField(max_length=100, db_index=True)
|
||||
pub_date = models.DateTimeField()
|
||||
|
||||
|
@ -53,14 +53,17 @@ class BookWeak(models.Model):
|
|||
|
||||
|
||||
class BookWithLongName(models.Model):
|
||||
author_foreign_key_with_really_long_field_name = models.ForeignKey(AuthorWithEvenLongerName)
|
||||
author_foreign_key_with_really_long_field_name = models.ForeignKey(
|
||||
AuthorWithEvenLongerName,
|
||||
models.CASCADE,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
apps = new_apps
|
||||
|
||||
|
||||
class BookWithO2O(models.Model):
|
||||
author = models.OneToOneField(Author)
|
||||
author = models.OneToOneField(Author, models.CASCADE)
|
||||
title = models.CharField(max_length=100, db_index=True)
|
||||
pub_date = models.DateTimeField()
|
||||
|
||||
|
@ -70,7 +73,7 @@ class BookWithO2O(models.Model):
|
|||
|
||||
|
||||
class BookWithSlug(models.Model):
|
||||
author = models.ForeignKey(Author)
|
||||
author = models.ForeignKey(Author, models.CASCADE)
|
||||
title = models.CharField(max_length=100, db_index=True)
|
||||
pub_date = models.DateTimeField()
|
||||
slug = models.CharField(max_length=20, unique=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue