I am working on a django project, where I want to implement a signal which should be called when some user address is changed. I have seen the built-in signals but they do not seem to work in my case, because if i use save that will be called in other save events as well and though I am able to create a custom signal, I could not find out, how should I call this ?
Please suggest.
Thanks in advance.
Start by defining a custom signal. A custom signal here is a sub class of
django.dispatch.Signal. This code can live inapp/signals.py.Next, make sure you send this signal when your user’s address is changed. Depending on how you have defined
UserandAddressthis can be done in different places. Let us assume that there is a view that lets users update theirAddressmodels. This code is presumably inapp/views.py.Now you need to set up a receiver for this signal.
Update
(After reading comment; the OP explains that there is no separate view that updates address) In that case you can try to override
User.save()to send out this signal. I say “try” because I do not know if you are using your ownUserclass orauth.User.