1👍
✅
You have such options:
- A routine. It can be made as a
Command
and something likecrontab
. Or it could be designed as aperiodiq
routine. This way you can repeatedly select allThing
models which have no relations withThingRelation
. signals.py
action. This way when entry ofThingRelation
is deleted, you should check both thefirst_thing
andsecond_thing
in order to know whether the have any moreThingRelation
relations pointing to them.- DB trigger (e.g. for PostgreSQL). The same idea as
signal.py
solution, but on DB level.
Which one should you choose? Depends on details of your exact objective. As for me, I use periodiq
option on simple cases and DB trigger if I aim on high performance.
Source:stackexchange.com