django build_absolute_uri 没有查询参数

adr*_*edo 1 django

request.build_absolute_uri()返回我url/path/?q1=v1&q2=v2...但是,我需要没有查询参数的相同绝对 uriq1=v1&q2=v2

Ala*_*air 5

build_absolute_uri方法有一个可选的location. 如果没有location提供,则使用get_full_path()包含查询字符串的内容。您可以传递request.path(不包括查询字符串)作为位置。

request.build_absolute_uri(request.path)
Run Code Online (Sandbox Code Playgroud)