Using signals for denormalizing counts
There are some cases when you would like to denormalize your data. Denormalization is making data redundant in a way that it optimizes read performance. You have to be careful about denormalization and only start using it when you really need it. The biggest issue you will find with denormalization is that it's difficult to keep your denormalized data updated.
We will take a look at an example of how to improve our queries by denormalizing counts. The drawback is that we have to keep the redundant data updated. We will denormalize data from our Image
model and use Django signals to keep the data updated.
Working with signals
Django comes with a signal dispatcher that allows receiver
functions to get notified when certain actions occur. Signals are very useful when you need your code to do something every time something else happens. You can also create your own signals so that others can get notified when an event happens.
Django provides several signals...