0
我在django视图中有以下POST方法。用卷曲测试django发布视图
def create_rule(request, rule_name, threshold, alert_value):
rule_name = request.GET.get('rule_name')
threshold = request.GET.get('threshold')
alert_value = request.GET.get('alert_value')
if request.method == 'POST' and rule_name is not None:
user = get_current_user(request)
rule = models.Rule(name=rule_name, user=user, threshold=threshold,
alert_value=alert_value, is_internal=False)
rule.save()
现在我要命令行卷曲如下:
curl --data "rule_name=TOTAL_REQUESTS&threshold=2&alert_value=2" http://localhost:8000/rules/create/
它抛出一个错误说服力。
Exception Type: TypeError at /rules/create/ Exception Value: create_rule() takes exactly 4 arguments (1 given)
我从卷曲传递的参数。为什么这个帖子没有收到这些信息。
不是一个好主意,从一个GET请求创建。修改数据库的操作应该是POST。 (想象一下,如果Googlebot抓取您的网站会发生什么情况。) – 2014-11-24 12:27:01
非常感谢您的评论 – station 2014-11-24 12:32:58