!说在前面(原创小文,如有需要请标明转载出处)
运行环境:
python3.8
django3
celery 4.4.2
需要安装的第三方包:
pip3 install celery==4.4.2
pip3 install django-celery-beat==2.0.0
一、Django项目settings配置
在INSTALLED_APPS中添加django_celery_beat
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'rest_framework.authtoken',
'django_celery_beat',
]
根据个人风格配置相关celery配置(这里本人使用的redis作为broker)
# celery相关配置
BROKER_URL = 'redis://:{password}@{host}:{port}/{db}'.format(password=REDIS_PWD, host=REDIS_HOST, port=REDI