How it works...
The ViralVideosAppConfig app configuration class has the ready() method, which will be called when all of the models of the project are loaded into the memory. According to the Django documentation, signals allow for certain senders to notify a set of receivers that an action has taken place. In the ready() method, therefore, we import the inform_administrators() function.
Through the @receiver decorator, inform_administrators() is registered for the post_save signal, and we have limited it to handle only the signals where the ViralVideo model is sender. Therefore, whenever we save a ViralVideo object, the receiver function will be called. The inform_administrators() function checks whether a video is newly created. If it ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access