Trying to migrate a field from cascade to "non-cascade" seems to be ignored (Django 1.10).
Previous model:
class Run(models.Model):
...
analysis_retention = models.ForeignKey('analysis_retention.AnalysisRetention',
null=True, default=None, on_delete=models.CASCADE)
New Model:
class Run(models.Model):
...
analysis_retention = models.ForeignKey('analysis_retention.AnalysisRetention',
null=True, default=None)
"manage.py makemigrations" doesn't detect the changes. Trying an explicit None doesn't help.
What would be the way to remove cascading?
Thanks
CASCADE
is default value for on_delete
argument, see source . So deleting on_delete=models.CASCADE
will not have effect. You need to specify on_delete
value in code:
analysis_retention = models.ForeignKey('analysis_retention.AnalysisRetention',
null=True, default=None, on_delete=models.SET_NULL)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.