{"id":23567,"library":"django-cron","title":"django-cron","description":"A Django app for running cron jobs within your Django project. Current version 0.6.0, with support for Django 4.0. Release cadence is sporadic, last release in 2023.","status":"active","version":"0.6.0","language":"python","source_language":"en","source_url":"https://github.com/tivix/django-cron","tags":["django","cron","scheduler","background-jobs"],"install":[{"cmd":"pip install django-cron","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Requires Django (minimum 1.8, supports up to 4.x)","package":"django","optional":false}],"imports":[{"note":"CronJobBase is a class in django_cron module, not from models","wrong":"from django_cron.models import CronJobBase","symbol":"CronJobBase","correct":"from django_cron import CronJobBase"},{"note":"","wrong":"","symbol":"Schedule","correct":"from django_cron import Schedule"},{"note":"Function is in the main django_cron module, not under management commands","wrong":"from django_cron.management.commands import get_current_cron_jobs","symbol":"get_current_cron_jobs","correct":"from django_cron import get_current_cron_jobs"}],"quickstart":{"code":"from django_cron import CronJobBase, Schedule\n\nclass MyCronJob(CronJobBase):\n    RUN_EVERY_MINS = 120  # every 2 hours\n    schedule = Schedule(run_every_mins=RUN_EVERY_MINS)\n    code = 'my_app.my_cron_job'  # a unique code\n\n    def do(self):\n        # your logic here\n        print(\"Cron job executed\")\n","lang":"python","description":"Define a cron job class, then run 'python manage.py runcrons' to execute jobs that are due."},"warnings":[{"fix":"Upgrade to django-cron >= 0.6.0.","message":"Django 4.0 support requires django-cron >= 0.6.0. Older versions will fail on Django 4.0 due to removed utc/unaware datetime handling.","severity":"breaking","affected_versions":"django-cron < 0.6.0 with Django >= 4.0"},{"fix":"Use integer minutes, e.g., RUN_EVERY_MINS = 1 instead of 0.5.","message":"RUN_EVERY_MINS must be an integer. Setting it to a float like 0.5 will raise an error because the lock file mechanism expects an integer.","severity":"gotcha","affected_versions":"all"},{"fix":"Define a 'schedule' attribute using django_cron.Schedule instead of relying on the old RUN_EVERY_MINS class attribute.","message":"The 'RUN_EVERY_MINS' attribute is deprecated in favor of specifying the schedule via a 'Schedule' object with 'run_every_mins' or 'run_at_times'. In future versions, using just RUN_EVERY_MINS may stop working.","severity":"deprecated","affected_versions":">= 0.6.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Upgrade to django-cron >= 0.5.1.","cause":"This error occurs when using Django 2.0+ with django-cron < 0.5.1 due to changes in datetime handling.","error":"'NoneType' object has no attribute 'utcoffset'"},{"fix":"Ensure each CronJob class has a unique 'code' attribute, and delete duplicate entries from the cron_jobs database table.","cause":"Having duplicate cron jobs with the same 'code' in the database. The runcrons command expects uniqueness.","error":"django_cron.models.CronJobBase.MultipleObjectsReturned"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}