summaryrefslogtreecommitdiff
path: root/docs/topics/forms/modelforms.txt
diff options
context:
space:
mode:
authorFlavio Curella <flavio.curella@gmail.com>2015-07-22 09:43:21 -0500
committerTim Graham <timograham@gmail.com>2015-07-27 18:28:13 -0400
commitc2e70f02653519db3a49cd48f5158ccad7434d25 (patch)
treec0f421a6b0c26a7716c380b3e360fecc74d553fb /docs/topics/forms/modelforms.txt
parent87d55081ea398c65b2503d22ed3907a9175ec729 (diff)
Fixed #21127 -- Started deprecation toward requiring on_delete for ForeignKey/OneToOneField
Diffstat (limited to 'docs/topics/forms/modelforms.txt')
-rw-r--r--docs/topics/forms/modelforms.txt14
1 files changed, 11 insertions, 3 deletions
diff --git a/docs/topics/forms/modelforms.txt b/docs/topics/forms/modelforms.txt
index 2e75695f53..e9898c6fff 100644
--- a/docs/topics/forms/modelforms.txt
+++ b/docs/topics/forms/modelforms.txt
@@ -1119,7 +1119,7 @@ you have these two models::
name = models.CharField(max_length=100)
class Book(models.Model):
- author = models.ForeignKey(Author)
+ author = models.ForeignKey(Author, on_delete=models.CASCADE)
title = models.CharField(max_length=100)
If you want to create a formset that allows you to edit books belonging to
@@ -1178,8 +1178,16 @@ need to resolve the ambiguity manually using ``fk_name``. For example, consider
the following model::
class Friendship(models.Model):
- from_friend = models.ForeignKey(Friend, related_name='from_friends')
- to_friend = models.ForeignKey(Friend, related_name='friends')
+ from_friend = models.ForeignKey(
+ Friend,
+ on_delete=models.CASCADE,
+ related_name='from_friends',
+ )
+ to_friend = models.ForeignKey(
+ Friend,
+ on_delete=models.CASCADE,
+ related_name='friends',
+ )
length_in_months = models.IntegerField()
To resolve this, you can use ``fk_name`` to