私は、各株式についての情報を表示する異なるモーダルを持つ仮想株式市場を作成しようとしています。 しかし、テンプレートはレンダリングして、各在庫に対して一意のモーダルヘッダーを取得できません。 各株式に固有のモーダルヘッダを取得するにはどうすればよいですか?
「CIPLA」の在庫をクリックしても、「HDFCを購入する」がモーダルヘッダーとして取得されます。 これは私のdjangoテンプレートです。
{% for stock in user.stocks.all %}
<li class="list-group-item">
<b>{{ stock.stock_name }}</b>
<p id="curr">Current price : {{ stock.current_price }}</p>
Bought at : {{ stock.buy_price }}
<button class="btn" id="buy" data-toggle="modal" data-target="#buy-modal">Buy</button>
<!--Modal for buy-->
<div id="buy-modal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Buy {{ stock.stock_name }}</h4>
</div>
<div class="modal-body">
<form method="post" action="/stocks/{{ user.id }}/{{ stock.stock_name }}/buy/" >
{% csrf_token %}
<label for="quantity">Quantity</label>
<input type="number" id="quantity-buy" name="quantity">
<button class="btn" id="confirm-buy" type="submit" >Buy</button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
私は{% endfor %}
で終了しました。
この回答を受け入れるには遅すぎるため、申し訳ありません。私は、あなたが何を言おうとしているかを理解するのに長い時間がかかりました。 –