我有一个接受 GET 参数的 View (可通过 request.GET 访问并且存在于 uri 中)
在 View 中,我想获取用于调用该 View 维护顺序的确切 uri
例子:
如果对 http://best.site.ever/?this=that&that=this 进行了调用,我希望能够在 View 中获取它
def best_view_ever(request):
calling_uri = get_calling_uri(request)
calling_uri # this should be http://best.site.ever/?this=that&that=this
这是否可以通过任何方式实现?
请您参考如下方法:
Django 请求对象有一个可用的辅助方法,称为 build_absolute_uri :
request.build_absolute_uri()
