ユーザーが受け取ったアイテムの数量を更新できる在庫システムのページを作成しようとしています。
すべての製品の表を表示し、受け取った数量をユーザーに入力させたいのですが、これを投稿して繰り返し、データベースを更新します。
これが私の見解です:
def new_shipment(request):
list_of_active_products = Product.objects.filter(status=1)
ShipmentFormSet = formset_factory(ShipmentForm, extra=0)
formset = ShipmentFormSet(initial=list_of_active_products)
return render_to_response('inventory/new_shipment.html', {'formset': formset})
フォームのモデルは次のとおりです。
class ShipmentForm(forms.Form):
sku = forms.IntegerField()
product_name = forms.CharField(max_length=100)
quantity = forms.IntegerField()
そして、これがフォームテンプレートです。
<form method="post" action="">
<table>
{% for form in formset %}
{{ form }}
{% endfor %}
</table>
<input type="submit" />
</form>
そして、これが私が得ているエラーです:
レンダリング中にAttributeErrorが発生しました:'Product'オブジェクトに属性'get'がありません
誰かがこれで私を助けることができますか?