$ show celery/django-celery-beat
django-celery-beat is a Django library that provides a database-backed scheduler for Celery Beat, allowing periodic task schedules to be stored and managed in a Django database. It offers models for interval, crontab, solar, and clocked schedules, with a full Django admin interface for CRUD operations. The core scheduler (`DatabaseScheduler`) reads enabled periodic tasks from the database and manages their execution, with change detection via a dedicated `PeriodicTasks` model. The codebase is production-stable, well-tested, and actively maintained, supporting recent Django (6.1) and Python (3.14) versions.
The LLM identified 4 files worth highlighting for reuse:
Implements `DatabaseScheduler` (a custom Celery Beat scheduler) and `ModelEntry` (schedule entry from DB rows). The scheduler reads enabled periodic tasks, detects changes via `PeriodicTasks.last_change()`, manages a heap of due times, and syncs state back to the database. The `ModelEntry` class handles schedule conversion (interval, crontab, solar, clocked) and due-date logic including start_time, one-off, and expiry. This is the core orchestration layer and is reusable in any project needing a dynamic DB-backed scheduler.
Provides custom field validators for crontab fields (minute, hour, day_of_month, etc.) using a custom `_CronSlices` subclass that raises `ValidationError` on invalid cron expressions. The validators are reusable for any Django model with cron expression fields and demonstrate careful handling of edge cases (zero-padded hours, ranges, steps).
Defines `TzAwareCrontab`, a subclass of Celery's `crontab` that respects a specific timezone for schedule calculation. It overrides `nowfunc` and `is_due` to convert `last_run_at` to the target timezone before computing due states. This is a clean, self-contained pattern for adding timezone support to any recurring schedule.
Implements `clocked`, a simple Celery schedule that runs a task at a fixed datetime (for one-off execution). It overrides `remaining_estimate` and `is_due` to return `NEVER_CHECK_TIMEOUT` after the clocked time passes. This is a minimal, reusable schedule type for single-point-in-time task execution.