django_celery_beat.models

Database models.

class django_celery_beat.models.ClockedSchedule(*args, **kwargs)

clocked schedule.

Parameters:
  • id (AutoField) – Primary key: ID

  • clocked_time (DateTimeField) – Clock Time. Run the task at clocked time

Reverse relationships:

Parameters:

periodictask (Reverse ForeignKey from PeriodicTask) – All periodic tasks of this clocked (related name of clocked)

exception DoesNotExist
exception MultipleObjectsReturned
class django_celery_beat.models.CrontabSchedule(*args, **kwargs)

Timezone Aware Crontab-like schedule.

Example: Run every hour at 0 minutes for days of month 10-15:

>>> minute="0", hour="*", day_of_week="*",
... day_of_month="10-15", month_of_year="*"
Parameters:
  • id (AutoField) – Primary key: ID

  • minute (CharField) – Minute(s). Cron Minutes to Run. Use “*” for “all”. (Example: “0,30”)

  • hour (CharField) – Hour(s). Cron Hours to Run. Use “*” for “all”. (Example: “8,20”)

  • day_of_month (CharField) – Day(s) Of The Month. Cron Days Of The Month to Run. Use “*” for “all”. (Example: “1,15”)

  • month_of_year (CharField) – Month(s) Of The Year. Cron Months (1-12) Of The Year to Run. Use “*” for “all”. (Example: “1,12”)

  • day_of_week (CharField) – Day(s) Of The Week. Cron Days Of The Week to Run. Use “*” for “all”, Sunday is 0 or 7, Monday is 1. (Example: “0,5”)

  • timezone (TimeZoneField) – Cron Timezone. Timezone to Run the Cron Schedule on. Default is UTC.

Reverse relationships:

Parameters:

periodictask (Reverse ForeignKey from PeriodicTask) – All periodic tasks of this crontab (related name of crontab)

exception DoesNotExist
exception MultipleObjectsReturned
class django_celery_beat.models.IntervalSchedule(*args, **kwargs)

Schedule executing on a regular interval.

Example: execute every 2 days:

>>> every=2, period=DAYS
Parameters:
  • id (AutoField) – Primary key: ID

  • every (IntegerField) – Number of Periods. Number of interval periods to wait before running the task again

  • period (CharField) – Interval Period. The type of period between task runs (Example: days)

Reverse relationships:

Parameters:

periodictask (Reverse ForeignKey from PeriodicTask) – All periodic tasks of this interval (related name of interval)

exception DoesNotExist
exception MultipleObjectsReturned
class django_celery_beat.models.PeriodicTask(*args, **kwargs)

Model representing a periodic task.

Parameters:
  • id (AutoField) – Primary key: ID

  • name (CharField) – Name. Short Description For This Task

  • task (CharField) – Task Name. The Name of the Celery Task that Should be Run. (Example: “proj.tasks.import_contacts”)

  • args (TextField) – Positional Arguments. JSON encoded positional arguments (Example: [“arg1”, “arg2”])

  • kwargs (TextField) – Keyword Arguments. JSON encoded keyword arguments (Example: {“argument”: “value”})

  • queue (CharField) – Queue Override. Queue defined in CELERY_TASK_QUEUES. Leave None for default queuing.

  • exchange (CharField) – Exchange. Override Exchange for low-level AMQP routing

  • routing_key (CharField) – Routing Key. Override Routing Key for low-level AMQP routing

  • headers (TextField) – AMQP Message Headers. JSON encoded message headers for the AMQP message.

  • priority (PositiveIntegerField) – Priority. Priority Number between 0 and 255. Supported by: RabbitMQ, Redis (priority reversed, 0 is highest).

  • expires (DateTimeField) – Expires Datetime. Datetime after which the schedule will no longer trigger the task to run

  • expire_seconds (PositiveIntegerField) – Expires timedelta with seconds. Timedelta with seconds which the schedule will no longer trigger the task to run

  • one_off (BooleanField) – One-off Task. If True, the schedule will only run the task a single time

  • start_time (DateTimeField) – Start Datetime. Datetime when the schedule should begin triggering the task to run

  • enabled (BooleanField) – Enabled. Set to False to disable the schedule

  • last_run_at (DateTimeField) – Last Run Datetime. Datetime that the schedule last triggered the task to run. Reset to None if enabled is set to False.

  • total_run_count (PositiveIntegerField) – Total Run Count. Running count of how many times the schedule has triggered the task

  • date_changed (DateTimeField) – Last Modified. Datetime that this PeriodicTask was last modified

  • description (TextField) – Description. Detailed description about the details of this Periodic Task

Relationship fields:

Parameters:
  • interval (ForeignKey to IntervalSchedule) – Interval Schedule. Interval Schedule to run the task on. Set only one schedule type, leave the others null. (related name: periodictask)

  • crontab (ForeignKey to CrontabSchedule) – Crontab Schedule. Crontab Schedule to run the task on. Set only one schedule type, leave the others null. (related name: periodictask)

  • solar (ForeignKey to SolarSchedule) – Solar Schedule. Solar Schedule to run the task on. Set only one schedule type, leave the others null. (related name: periodictask)

  • clocked (ForeignKey to ClockedSchedule) – Clocked Schedule. Clocked Schedule to run the task on. Set only one schedule type, leave the others null. (related name: periodictask)

Reverse relationships:

Parameters:

o2otoperiodictasks (Reverse OneToOneField from O2OToPeriodicTasks) – The o2o to periodic tasks of this periodic task (related name of periodictask_ptr)

exception DoesNotExist
exception MultipleObjectsReturned
save(*args, **kwargs)

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

validate_unique(*args, **kwargs)

Check unique constraints on the model and raise ValidationError if any failed.

class django_celery_beat.models.PeriodicTasks(*args, **kwargs)

Helper table for tracking updates to periodic tasks.

This stores a single row with ident=1. last_update is updated via signals whenever anything changes in the PeriodicTask model. Basically this acts like a DB data audit trigger. Doing this so we also track deletions, and not just insert/update.

Parameters:
exception DoesNotExist
exception MultipleObjectsReturned
class django_celery_beat.models.SolarSchedule(*args, **kwargs)

Schedule following astronomical patterns.

Example: to run every sunrise in New York City:

>>> event='sunrise', latitude=40.7128, longitude=74.0060
Parameters:
  • id (AutoField) – Primary key: ID

  • event (CharField) – Solar Event. The type of solar event when the job should run

  • latitude (DecimalField) – Latitude. Run the task when the event happens at this latitude

  • longitude (DecimalField) – Longitude. Run the task when the event happens at this longitude

Reverse relationships:

Parameters:

periodictask (Reverse ForeignKey from PeriodicTask) – All periodic tasks of this solar event (related name of solar)

exception DoesNotExist
exception MultipleObjectsReturned
django_celery_beat.models.cronexp(field)

Representation of cron expression.

django_celery_beat.models.crontab_schedule_celery_timezone()

Return timezone string from Django settings CELERY_TIMEZONE variable.

If is not defined or is not a valid timezone, return "UTC" instead.