嗨,所以我有這種方法在Django的意見將文件發佈到不同的服務器。抱怨請求的媒體類型,我得到一個HTTP 415錯誤。我調試了請求並將其內容複製並粘貼在提琴手中。當我從小提琴手張貼相同的作品。所以我不明白爲什麼它不能使用python請求包。如何發佈一個Django請求到外部服務器
任何人都可以幫助我嗎?
謝謝。
def upload(request):
if request.method == 'POST':
url=settings.WEBSERVICES_URL+'validate'
r = requests.post('http://localhost:9090/validate',data=request)
r2 = requests.get('http://localhost:9090/test')
return render_to_response("upload.html", context_instance=RequestContext(request))
else:
return render_to_response("upload.html", context_instance=RequestContext(request))
嗨,感謝您的回覆。現在的問題是當調用requests.post時,不會替換localhost:8000的POST url。由於表單發佈到本地主機:8000 /最初上傳到視圖中的上傳方法POST URL不正確。我希望這些請求會取代它,但它不會 –