Celery 3.1 now supports Django out of the box, please see the new tutorial
Views - djcelery.views¶
-
djcelery.views.
JsonResponse
(response)¶
-
djcelery.views.
apply
(request, task_name)¶ View applying a task.
- Note: Please use this with caution. Preferably you shouldn’t make this
- publicly accessible without ensuring your code is safe!
-
djcelery.views.
is_task_successful
(request, task_id)¶ Returns task execute status in JSON format.
-
djcelery.views.
registered_tasks
(request)¶ View returning all defined tasks as a JSON object.
-
djcelery.views.
task_status
(request, task_id)¶ Returns task status and result in JSON format.
-
djcelery.views.
task_view
(task)¶ Decorator turning any task into a view that applies the task asynchronously. Keyword arguments (via URLconf, etc.) will supercede GET or POST parameters when there are conflicts.
- Returns a JSON dictionary containing the keys
ok
, and task_id
.
- Returns a JSON dictionary containing the keys
-
djcelery.views.
task_webhook
(fun)¶ Decorator turning a function into a task webhook.
If an exception is raised within the function, the decorated function catches this and returns an error JSON response, otherwise it returns the result as a JSON response.
Example:
@task_webhook def add(request): x = int(request.GET['x']) y = int(request.GET['y']) return x + y def view(request): response = add(request) print(response.content)
Gives:
"{'status': 'success', 'retval': 100}"