Py学习  »  Django

django关于?后的参数传递问题

302790951 • 8 年前 • 2279 次点击  

网上大多都是 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'))

求解决办法 感谢!

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/1182
 
2279 次点击  
文章 [ 2 ]  |  最新文章 8 年前
302790951
Reply   •   1 楼
302790951    8 年前

@shen_gan 感谢,是我写的有问题 不是request.GET.get('query')的问题

shen_gan
Reply   •   2 楼
shen_gan    8 年前

看看是不是你的这个index函数没有request这个参数?