查看所有参数
from django.core.handlers.wsgi import WSGIRequest
def test(request):
print(type(request)) # 打印出request的类型
print(request.environ) # 打印出request的header详细信息
# 循环打印出每一个键值对
for k, v in request.environ.items():
print(k, v)
获取请求参数
POST GET获取
def filter_books(objects, request):
filter_author = request.POST['author']
if (filter_author):
objects = objects.filter(author__icontains=filter_author)
return objects
网友评论