我正在尝试使用 django request.post 调用 API,但收到错误 405 'Method Not Allowed (POST)' urls:
path('ciu_consume/<str:br>/<int:qty>/', CiuConsumeView.as_view())
view:
class CiuConsumeView(APIView):
def dispatch(self, *args, **kwargs):
return super().dispatch(*args, **kwargs)
def get(self, request, br, qty):
import pdb;pdb.set_trace()
Response = requests.put('http://inv****.***.***.c***y.in/**/**/***/***/',
data={'br': br, 'qty': 1})
return HttpResponse('Success')
在这我收到错误 404
如果不是'def get()'我调用'def post',那么我也会得到同样的错误。真的卡在这上面了。对此的任何帮助都会有所帮助。
<form id="form" method="post">{% csrf_token %}
<table class="table table-hover" id="table_id" class="display display nowrap">
<thead>
<tr>
<th>S. No.</th>
<th>barcode</th>
<th>product name</th>
<th>SKU</th>
<th>Quantity</th>
<th>product ID</th>
<th>Colour Code</th>
<th>Status</th>
<th>Mark Loss</th>
</tr>
</thead>
<tbody>
{% for in_dict in in_dict %}
<tr>
<td>{{ forloop.counter }}</td>
<td>{{ in_dict.br }}</td>
<td>{{ in_dict.p_name }}</td>
<td>{{ in_dict.sku }}</td>
<td>{{ in_dict.qty }}</td>
<td>{{ in_dict.p_id }}</td>
<td>{{ in_dict.clr_code }}</td>
<td>{{ in_dict.status }}</td>
<td><input type="button" name="consume" class="btn btn-success" value="consume" onclick="window.location.href='/api/admin-apis/ciu_consume/{{ in_dict.br }}/{{ in_dict.qty }}/';"></td>
</tr>
{% endfor %}
</tbody>
</table>
</form>