将POST或GET请求数据设置为manage.py shell中的QueryDict

时间:2012-10-11 20:26:02

标签: python django

django.http.HttpRequest中的manage.py shell对象没有GETPOST属性。是否真的无法将我的Django视图中的POSTGET数据从其中一个网址设置为QueryDict中的manage.py shell

1 个答案:

答案 0 :(得分:1)

你可以粘贴你输入的内容吗?我可以将数据添加到GET字典。

(stackoverflow)➜  my_project  python ./manage.py shell
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.http import HttpRequest
>>> req = HttpRequest()
>>> print req
<HttpRequest
path:,
GET:{},
POST:{},
COOKIES:{},
META:{}>
>>> req.GET['test'] = 'hello world'
>>> print req
<HttpRequest
path:,
GET:{'test': 'hello world'},
POST:{},
COOKIES:{},
META:{}>
>>>