URL参数获取
http://127.0.0.1:8000/crm/add_edit_customer/22/?next=%2Fcrm%2Fcustomers%2F%3Fsearch_field%3Dqq__contains%26kw%3D111
想要获取/22/,需要后端声明(id)为获取的参数,def add_edit_customer(request,id)
想要获取%2Fcrm%2Fcustomers%2F%3Fsearch_field%3Dqq__contains%26kw%3D111(%2F等:为urlencode编码,是为了防止request获取时,以&分隔,无法获得整个字符串),直接request.GET.get('next')就可以
*例如:
Q= QueryDict(mutable=True)
get_data = request.GET.copy()
next = /crm/customers/?search_field=qq__contains&kw=111
request.GET,获取到的是 :<QueryDict: {'search_field': ['qq__contains'], 'kw': ['111']}>
request.path 获取到的是:/customers/
urlencode()后变成:
next = %2Fcrm%2Fcustomers%2F%3Fsearch_field%3Dqq__contains%26kw%3D111