19 request请求数据大全

1 request.path_info

# 获取当前用户请求的url
# http://127.0.0.1:8000/customer/list/         ----> /customer/list/
# http://127.0.0.1:8000/customer/list/?age=19  ----> /customer/list/
print(request.path_info)

2 request.method

# 获取当前用户请求方式:(GET/POST)
print(request.method)

3 request.POST

# 获取当前用户POST请求数据
print(request.POST)
# <QueryDict: {'csrfmiddlewaretoken': ['jdoNHfaNRIBlLCM8QXbLJld8XP4UYehyh8ykrW4erOuB83aaFH3YNJQlnGzm7qo9'], 'username': ['123'], 'password': ['123']}>

# 获取单个数据
request.POST.get('xx')
# 获取多个数据
request.POST.getlist('xx')

4 request.FILES

文件

posted @ 2022-08-25 16:49  角角边  Views(29)  Comments(0Edit  收藏  举报