Im having a problem with Django 2.1 and on_delete mandatory field.
I have an ORM like this:
class Slideshow(models.Model):
bla bla
dashboards = models.ManyToManyField(
Dashboard,
through='SlideshowDashboard',
through_fields=('slideshow','dashboard')
)
class SlideshowDashboard(models.Model):
dashboard = models.ForeignKey(Dashboard, on_delete = CASCADE)
slideshow = models.ForeignKey(Slideshow, on_delete = CASCADE)
slide_time_dashboard = models.DurationField(null = True, blank = True)
slide_order = models.IntegerField(null = True, blank = True)
Dashboard is another Model.
When updating the information about Slideshow, I need to TRUNCATE all previous Dashboards associated to Slideshow to save the new list.
So I use:
slideshow_to_save.dashboards.all().delete()
Unfortunally, and I don't know why, this command delete the Dashboard related entry in Dashboard table.
By specific, on_delete should delete SlideshowDashboard if I delete a Dashboard, not the opposite.