0
我有一個Django應用程序,它提供了一個使用美味派的RESTful API。Python請求和404錯誤與Django /美味派
我正在使用Django的開發runserver
進行測試。
當我通過它工作正常瀏覽器訪問它,並使用curl也能正常工作:
curl "http://localhost:8000/api/v1/host/?name__regex=&format=json"
在用的runserver控制檯上,我看到:
[02/Oct/2012 17:24:20] "GET /api/v1/host/?name__regex=&format=json HTTP/1.1" 200 2845
然而,當我嘗試要使用Python請求模塊(),我得到一個404作爲輸出:
>>> r = requests.get('http://localhost:8000/api/v1/host/?name__regex=&format=json')
>>> r
<Response [404]>
或:
>>> r = requests.get('http://localhost:8000/api/v1/host/?name__regex=&format=json')
>>> r
<Response [404]>
此外,Django的runserver命令控制檯上,我看到:
[02/Oct/2012 17:25:01] "GET http://localhost:8000/api/v1/host/?name__regex=&format=json HTTP/1.1" 404 161072
出於某種原因,當我使用的要求,它打印出整個請求的URL,包括本地主機 - 但不是當我使用瀏覽器或捲曲。
我假設這是與它的編碼,用戶代理或請求類型發送?