mirror of
https://github.com/django/django.git
synced 2025-11-01 04:17:59 +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
|
|
@ -40,7 +40,7 @@ database-schema problems. Here's a quick example:
|
|||
pub_date = models.DateField()
|
||||
headline = models.CharField(max_length=200)
|
||||
content = models.TextField()
|
||||
reporter = models.ForeignKey(Reporter)
|
||||
reporter = models.ForeignKey(Reporter, on_delete=models.CASCADE)
|
||||
|
||||
def __str__(self): # __unicode__ on Python 2
|
||||
return self.headline
|
||||
|
|
@ -154,7 +154,7 @@ as easy as registering your model in the admin site:
|
|||
pub_date = models.DateField()
|
||||
headline = models.CharField(max_length=200)
|
||||
content = models.TextField()
|
||||
reporter = models.ForeignKey(Reporter)
|
||||
reporter = models.ForeignKey(Reporter, on_delete=models.CASCADE)
|
||||
|
||||
.. snippet::
|
||||
:filename: mysite/news/admin.py
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ These concepts are represented by simple Python classes. Edit the
|
|||
|
||||
|
||||
class Choice(models.Model):
|
||||
question = models.ForeignKey(Question)
|
||||
question = models.ForeignKey(Question, on_delete=models.CASCADE)
|
||||
choice_text = models.CharField(max_length=200)
|
||||
votes = models.IntegerField(default=0)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue