Regarding pre_save signal, it is useful for doing something with the "old"
instance. Consider a use case where you might want to "archive" all changes
to, say, the user's profile. Every time a user makes a change to their
profile, you want to save the current state of the profile to another
table, or another database, and then save the new model (which overwrites
the current state and becomes the new current state). This sort of
mechanism is useful for versioning your model instances. The pre_save
signal allows you to create a hook that does precisely that. That is just
one of the use cases, but I'm sure you can think of others.

Karl Sutt


On Sat, May 12, 2012 at 10:46 AM, Alireza Savand
<alireza.sav...@gmail.com>wrote:

> Hi
>
> What is the different between pre_save signal and post_save singal.
> I know post_save will emited after model instance saved, and pre_save is
> before the saving the instance[?]
> but what it the point of pre_save when we cannot access the object data
> before the data changes.
> I mean user try to change the model content, like body of a post in a
> blog. using pre_save signal would be reasonable if i can access the post's
> body before the changes or in other word before the actual save() happens.
> If i can't access to data before save() happends, So what is the point of
> pre_save ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/NLEgGtpvQ4cJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to