Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python django-获取用于调用django视图(包括参数)的确切Get url_Python_Django - Fatal编程技术网

Python django-获取用于调用django视图(包括参数)的确切Get url

Python django-获取用于调用django视图(包括参数)的确切Get url,python,django,Python,Django,我有一个接受GET参数的视图(可通过请求.GET访问,并且这些参数存在于uri中) 在视图中,我想获得用于调用该视图的确切uri 例如: 如果呼叫http://best.site.ever/?this=that&that=this我希望能够在视图中获取它 def best_view_ever(request): calling_uri = get_calling_uri(request) calling_uri # this should be http://best.site.

我有一个接受GET参数的视图(可通过
请求.GET访问,并且这些参数存在于uri中)

在视图中,我想获得用于调用该视图的确切uri

例如:

如果呼叫
http://best.site.ever/?this=that&that=this
我希望能够在视图中获取它

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\u absolute\u uri
请求对象的方法在这里会很有用

def get_calling_uri(request):
    return request.build_absolute_uri()

def best_view_ever(request):
    calling_uri = get_calling_uri(request)
    print calling_uri # this should be http://best.site.ever/?this=that&that=this
def get_calling_uri(request):
    return request.build_absolute_uri()

def best_view_ever(request):
    calling_uri = get_calling_uri(request)
    print calling_uri # this should be http://best.site.ever/?this=that&that=this