Django 4.2: Difficulty Configuring Celery with Django for Periodic Tasks Using Redis
I'm having trouble setting up Celery to work with Django 4.2 and Redis for periodic tasks. I've followed the official documentation, but my tasks aren't executing as expected. I set up a simple task in `tasks.py` like this: ```python from celery import shared_task @shared_task def add(x, y): return x + y ``` In my `settings.py`, I've configured Celery with Redis as follows: ```python CELERY_BROKER_URL = 'redis://localhost:6379/0' CELERY_RESULT_BACKEND = 'redis://localhost:6379/0' CELERY_ACCEPT_CONTENT = ['json'] CELERY_TASK_SERIALIZER = 'json' CELERY_TIMEZONE = 'UTC' CELERY_BEAT_SCHEDULE = { 'add-every-30-seconds': { 'task': 'myapp.tasks.add', 'schedule': 30.0, 'args': (16, 16), }, } ``` I also added Celery to my `wsgi.py` file: ```python import os from celery import Celery os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings') app = Celery('myproject') app.config_from_object('django.conf:settings', namespace='CELERY') app.autodiscover_tasks() ``` However, when I start Celery with the command `celery -A myproject worker -l info` and `celery -A myproject beat -l info`, I see no logs indicating that the periodic task is running. I also checked the Redis server, and it seems to be running fine. The only behavior I occasionally get is `Task myapp.tasks.add[<task_id>] not registered`. I've confirmed that the task is correctly defined in the right module and that I'm using the correct import path. What could be wrong with my configuration? Any help would be greatly appreciated! My development environment is Linux.