【发布时间】:2020-06-16 16:18:23
【问题描述】:
我有一个提交表单,例如:
<div class="form-group">
<div class="checkbox">
<label for="id_active_state">
<div class="icheckbox_square-red checked" style="position: relative;">
<input type="checkbox" name="active_state" class="" id="id_active_state" checked=""><ins class="iCheck-helper"></ins>
</div> active</label>
</div>
</div>
<div class="form-group">
<div class="button_holder">
<button type="submit" name="submit" class="btn btn-primary" value="send">
submit
</button>
</div>
</div>
而且应该在视图中处理:
def special_offer_edit_view(http_request):
action_verbose_name = 'the_view'
special_offer_id = http_request.GET.get('id')
special_offer_obj = SpecialOffer.objects.filter(id=special_offer_id)
for data in special_offer_obj:
sp_obj = {'active_state': data.active_state}
if http_request.method == 'POST':
print('hi')
return render(...)
它引发 503 错误,并且不发送“POST”方法和数据。它的问题是什么?
【问题讨论】:
-
您在输入字段和提交按钮周围缺少
<form action="whereYourActionTakesPlace" method="POST">。您的字段不知道 a) 他们应该使用 post (method) 和 b) 它应该指向 (action) 的位置。
标签: python html django post django-views