首页 > 其他 > 详细

request.get_full_path() 和request.path区别

时间:2018-09-30 10:01:39      阅读:174      评论:0      收藏:0      [点我收藏+]

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 

 

request.get_full_path() 和request.path区别

原文:https://www.cnblogs.com/zhongbokun/p/9728089.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!