Here's how my project is organized.

electron /
  ...
  electron / <----- sources root (pycharm)
    ...
    electron /
      ...
      celery.py
      settings.py
    tasks /
      tasks.py <----- Here are my tasks

celery beat configuration in settings.py

from celery.schedules import crontab 
from tasks import tasks
   
CELERY_BEAT_SCHEDULE = {
        "toutes-les-minutes": {
            "task": "tasks.tache_journaliere",
            "schedule": crontab(minute="*/1"),
        },
    }

When I import my tasks like this: from ..tasks import tasks. I get the following error:

ImportError: attempted relative import beyond top-level package

When I import tasks like this: from tasks import tasks,the following error occurs

django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

I've been trying to correct these errors for a while, but it doesn't work. I even looked for solutions here. I still can't.

Is it not possible to configure periodic tasks outside of the settings.py file? (in the celery.py file for example)

0

There are 0 answers