1

I think that anything that can be done with signal also can be done by overriding save() method in Model.

If so, why do we need a signal? I can not find when to use the signal.

Thanks

user3595632
  • 5,380
  • 10
  • 55
  • 111
  • Does this answer your question? [Django signals vs. overriding save method](https://stackoverflow.com/questions/170337/django-signals-vs-overriding-save-method) – Flimm Dec 04 '19 at 13:22

2 Answers2

1

I think this may clarify your doubts :

About Django signals and override save method

Basically, people overrides save method to manipulate data from models before or after execute saving, signals are done precisely to cover the more possibilities of that scenario without alterations.

jsanchezs
  • 1,992
  • 3
  • 25
  • 51
0

There are many situations when use of signal is essential. Since you are comparing with overiding save() method this example will give you one such scenario of use post_save signal. With post_save signal you can access the entire data stored in your database prior to the signal i.e. it will also provide you auto generated id of the data just stored by your database ( whether mysql, postgresql , mongodb etc. ). This can be used if you are saving two models with single save() function and want to link the two with same autogenerated pk.

trigo
  • 387
  • 1
  • 7
  • Could you please give me some examples? I think that `save()` also access the entire data stored in the database? – user3595632 Feb 19 '18 at 08:30