网上大多都是 request.GET.get('q')获取到?后的参数
但是我实际测试会报错如下:
AttributeError at /index/
'module' object has no attribute 'GET'
Request Method: GET
Request URL: http://127.0.0.1:2333/index/
Django Version: 1.7.5
Exception Type: AttributeError
Exception Value:
'module' object has no attribute 'GET'
Exception Location: /Users/izy/Documents/webserver/web/pyweb/pyweb/pyweb/index.py in index, line 24
Python Executable: /usr/bin/python
Python Version: 2.7.6
代码如下
from django.http import request
from django.http import HttpResponse
def index(req):
return HttpResponse(request.GET.get('query'))
求解决办法 感谢!