BelgarionCrezo
BelgarionCrezo

Reputation: 25

Show task in view (started, success, failed)

I successfully set my django server and have celery linked with it. I can show all the task in the administration interface in the DjCelery tables.

But I want to be able to display some similar information in one of my view. How can I browse this table to get all the information about the task listed ? Is it any SQL request or python equivalent that I can put in my views.py file to get all those task ?

Upvotes: 1

Views: 78

Answers (1)

Thomas Kremmel
Thomas Kremmel

Reputation: 14783

Everything that is displayed in the admin can be displayed in a custom view, as the admin only displays data available in the database. See the github source to see which models are registered for the admin.

As the task state is stored in the model TaskState you can fetch the task status via the following query:

from djcelery.models import TaskState

task_states = TaskState.objects.all()
for state in task_states:
    print state.name
    print state.state

Upvotes: 1

Related Questions