因为请求对象包含对不实际序列化的内容的引用(例如上载的文件或与请求关联的套接字),所以没有通用的方法来对其进行序列化。
相反,您应该拔出并传递需要的部分。例如,类似:
import tempfile@app.taskdef location(user_id, uploaded_file_path): # … do stuff …def tag_location(request): with tempfile.NamedTemporaryFile(delete=False) as f: for chunk in request.FILES["some_file"].chunks(): f.write(chunk) tasks.location.delay(request.user.id, f.name) return JsonResponse({'response': 1})


