Get the requested URL from django request

created at 07-17-2021 views: 9

django request Get the requested URL

  • request.get_host(): Get the request address
  • request.path: Get the requested path without parameters
  • request.path_info: Get the requested path without parameters
  • request.get_full_path(): Get complete parameters

Suppose the current URL is:

request.get_host()    # 

request.path          # article/730.html

request.get_full_path() article/730.html?a=1

Stupid way:

from urllib import parse



Elegant approach


created at:07-17-2021
edited at: 07-17-2021: