django + celery - How do I set up a crontab schedule for celery in my django app?
celery, cron, django
Solution
This happens because you have a `celery.py` file in the same package as your `settings.py`, which shadows the global `celery` package.
To get around this, insert the following string at the beginning of the settings.py:
from __future__ import absolute_import
Hope it helps!
Problem
I am following the instructions here: http://celery.readthedocs.org/en/latest/userguide/periodic-tasks.html#crontab-schedules I'm supposed to be able to do the following: `from celery.schedules import crontab` In my `settings.py` I have: ``` from kombu import serialization serialization.registry._decoders.pop("application/x-python-serialize") import djcelery djcelery.setup_loader() from celery.schedules import crontab ... CELERYBEAT_SCHEDULE = { 'first_task': { 'task': 'apps.icecream.tasks.sync_flavors', 'schedule': crontab(minute='*/30', hour='1, 3, 6, 8-20, 22') }, 'second_task': { 'task': 'apps.robots.tasks.run_robots', 'schedule': crontab(minute='*/6') } } ``` However, I'm getting an error: "No module named schedules" If I switch to the other way of scheduling, using timedelta, then everything is fine and I can get my periodic tasks to run: ``` CELERYBEAT_SCHEDULE = { 'first_task': { 'task': 'apps.icecream.tasks.sync_flavors', 'schedule': timedelta(minutes=30) }, 'second_task': { 'task': 'apps.robots.tasks.run_robots', 'schedule': timedelta(minutes=6) } } ``` Why can't I use the crontab approach?