How to properly configure djcelery results backend to database

随声附和 提交于 2019-12-02 19:37:30

Check the doc, when you use djcelery, set CELERY_RESULT_BACKEND="database" or don't even bother to write this line because djcelery sets it by default.

The result is stored in celery_taskmeta table, you should register djcelery.models.TaskMeta to admin by yourself:

# in some admin.py, which is contained by an app after `djcelery` in `INSTALLED_APPS`
# or directly in djcelery/admin.py

from djcelery.models import TaskMeta
class TaskMetaAdmin(admin.ModelAdmin):
    readonly_fields = ('result',)    
admin.site.register(TaskMeta, TaskMetaAdmin)
Andrey Shamakhov

Related question with right answer is here.

You should actually run

python manage.py celery worker -E

and

python manage.py celerycam

After that tasks results will be displayed in admin (Djcelery › Tasks)

Moving the config update e.g.
app.conf.update(CELERY_RESULT_BACKEND='djcelery.backends.database.DatabaseBackend')

to the end of file celery.py did the trick for me .

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!