首页 > 技术文章 > request.get_full_path() 和request.path区别

zhongbokun 2018-09-30 09:47 原文

1. 都是获取request 请求的url路径

2. request.get_full_path() -- 获取当前url,(包含参数)

     请求一个http://127.0.0.1:8000/200/?type=10

      request.get_full_path()返回的是【/200/?type=10】

     request.path --  获取当前url,(但不含参数)

      request.path返回的是 【/200/】

3. 如果想让其正常显示(有中文的情况下),需进行如下编码处理【django 默认编码是unicode 的】

 

request.get_full_path().encode('utf-8')
request.path.encode('utf-8')

 

--------------------- 本文来自 qin147896325 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/zd147896325/article/details/79166396?utm_source=copy 

 

推荐阅读