views:

34

answers:

1

I am using Django's pre_save signal to implement auto_now_add. There is a lot of discussion on the internet on why you should or shouldn't implement it yourself. I do not appreciate comments on this. Neither on whether I should be rewriting the save function (I have a lot of models that use auto_now_add so using signals makes sense).

My question is:
I would like to check if the instance is created or updated. According to some sources on the internet this can be done by testing if kwargs['created'] is True. However 'created' does not appear in my kwargs even though the instance is newly created. I was just wondering if it has ever existed or that it has disappeared magically. I know I could also test if kwargs['instance'].id is set (this in fact works for me), but I'd like to know if kwargs['created'] still exists.

A: 

According to the latest Django documentation, pre_save does NOT send a created argument. Post_save however does. I could not find any reference of the signal sending created since version 1.0.

Manoj Govindan
Thank you very much for your reply. I must have misread the sources and assumed that 'created' also appeared in the pre_save signal. It actually makes sense when you think about it.Thanks for clearing this up for me!
Heyl1