Let's get into some real-world example applications of Celery. Suppose another page on our site now requires a reminders feature. Users can create reminders that will send an email to a specified location at a specified time. We will need a model, a task, and a way to call our task automatically every time a model is created.
Let's start with the following basic SQLAlchemy model:
class Reminder(db.Model): id = db.Column(db.Integer(), primary_key=True) date = db.Column(db.DateTime()) email = db.Column(db.String()) text = db.Column(db.Text())
def __repr__(self): return "<Reminder '{}'>".format(self.text[:20])
Now, we need a task that will send an email to the location in the model. In our blog/tasks.py file, look up the following task:
@celery.task(
bind=True,
ignore_result=True...