django-celery 应用方法
*************settings
import djcelery
djcelery.setup_loader()
BROKER_URL='redis://:mima@1.1.11.1:6379/0'
#redis://密码@ip:6379/0
CELERY_RESULT_BACKEND='redis://:omima@1.1.11.1:6379/0'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TIMEZONE = 'Africa/Nairobi'
CELERY_IMPORTS=['app01.task']
#task路径
from datetime import timedelta
![](https://images2018.cnblogs.com/blog/1152610/201807/1152610-20180717151655984-115976596.png)
--------------celery.py 文件
![](https://images2018.cnblogs.com/blog/1152610/201807/1152610-20180717151719062-1648988317.png)
############task.py
任务方法
![](https://images2018.cnblogs.com/blog/1152610/201807/1152610-20180717151739055-2045162664.png)
------------------------template
![](https://images2018.cnblogs.com/blog/1152610/201807/1152610-20180717151823955-1163846521.png)
![](https://images2018.cnblogs.com/blog/1152610/201807/1152610-20180717151829938-61016793.png)
![](https://images2018.cnblogs.com/blog/1152610/201807/1152610-20180717151907733-484339899.png)
------------view 视图函数
![](https://images2018.cnblogs.com/blog/1152610/201807/1152610-20180717152009585-1719416015.png)