0

中的django.http.HttpRequest对象manage.py shell没有GETorPOST属性。真的没有办法设置与我的 Django 视图中的相同POST或数据,从它的一个 url到?GETQueryDictmanage.py shell

4

1 回答 1

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:{}>
>>>
于 2012-10-11T20:31:01.190 回答