【发布时间】:2017-11-17 22:03:44
【问题描述】:
我的url.py如下,
from myapp import views
urlpatterns = [
url(r'^myapp/get_requests/$', views.get_requests),
]
现在我的views.py如下,
@api_view(['GET'])
def get_request(request):
#How can I get request ID (base url here)?
return HttpResponse('test')
在上面,如果我在浏览器中使用以下 url 请求它会到达我的 get_request 方法,
http://localhost:8080/myapp/get_requests/
但是当我尝试使用下面的一些 ID 时,同样会出现错误 404,
http://localhost:8080/myapp/get_requests/40
现在我怎样才能在我的views.py方法中得到这个ID号40?
【问题讨论】:
-
创建一个允许发布请求的函数,其中您将 id 作为有效负载.....转到stackoverflow.com/questions/16789988/…了解如何
标签: python django django-rest-framework