﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
21640	ForeignKey.on_delete doesn't call models save function.	traverse.da@…	nobody	"I'm trying to get three things to happen when a ForeignKey on my ""post"" model gets deleted. The foreignkey needs to get set to null, which is fine. Just add ForeignKey.on_delete.SET_NULL to the model.

The second is to set draft (another field on ""post"") to ""True"". I also want to call a celery task.

My first solution was to put something like this in the projects save function

def save(self):
    if not self.thumbnail:
        self.draft=True
        thumnailtask.delay(self.pk) #starts a celery task, not really relevant.
    super(post, self).save()

That works great when I manually save an object. 

But when an object thumbnail gets deleted, it doesn't call that. There's no way to start a task, or one any kind of logic when a ForeignKey gets deleted. ForeignKey.SET() doesn't seem to have access to the post's PK, so I can't say something like ForeignKey.SET(thumbnailtask_returns_null(pk)).

I think that ideally, ForeignKey.SET would simply call the post's save function."	New feature	closed	Database layer (models, ORM)	1.5	Normal	wontfix			Unreviewed	0	0	0	0	0	0
