当我将我的项目投入生产时,即使使用 runserver 测试,也没有引发此错误,但是当我使用gunicorn --bind 进行测试时,会发生这种情况
导入操作系统 从芹菜进口芹菜
# Set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sqh.settings.dev')
app = Celery('sqh',broker_url = 'redis://localhost:6379/0')
# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
# should have a `CELERY_` prefix.
app.config_from_object('django.conf:settings', namespace='CELERY')
# Load task modules from all registered Django apps.
app.autodiscover_tasks()
#@app.task(bind=True)
#def debug_task(self):
# print(f'Request: {self.request!r}')
导入错误:无法导入名称 Celery
更改模块名称。示例:celery_module.py