How to properly configure djcelery results backend to database

后端 未结 3 1484
萌比男神i
萌比男神i 2021-02-02 02:04

I\'m trying to setup djangocelery to store task results in the databse.

I set:

CELERY_RESULT_BACKEND = \'djcelery.backends.database.DatabaseBackend\'
         


        
3条回答
  •  礼貌的吻别
    2021-02-02 02:47

    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)
    

提交回复
热议问题