Using signals to notify administrators about new entries

Django framework has a concept of signals, which are similar to events in JavaScript. There is a handful of built-in signals that you can use to trigger actions before and after initialization of a model, saving or deleting an instance, migrating the database schema, handling a request, and so on. Moreover, you can create your own signals in your reusable apps and handle them in other apps. In this recipe, you will learn how to use signals to send emails to administrators whenever a specific model is saved.

Getting ready

Let's start with the viral_videos app that we created in the Using database query expressions recipe.

How to do it...

Follow these steps to create notifications to administrators: ...

Get Web Development with Django Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.