【发布时间】:2021-12-21 16:32:36
【问题描述】:
是否可以在 django 项目中的 celery 任务中访问 requests.POST/GET 方法?我读过这是不可能的,因为 celery 无法序列化请求 JSON 对象。除了从 requests.POST['data'] 对象中获取数据并将它们传递给 celery 任务之外,还有其他解决方法吗?
def index(request):
task = run_tasks.delay(request) # I would like to pass the request data to the task
return render(request, 'example/index.html', {'task_id': task.task_id})
【问题讨论】:
标签: django python-requests celery