I need assistance with extracting a list of objects and placing them in a dropdown menu. I have successfully achieved this, but the issue seems to be related to my HTML structure. Here is the code snippet from my HTML:
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Choose an existing structure<span class="caret"></span></button>
<ul class="dropdown-menu">
{% for s in structures %}
<li>{{ s.name }}</li>
{% endfor %}
</ul>
</div>
Previously, I utilized similar code to display structures in a table in a different HTML template and it worked just fine. Here is the working code:
<tbody>
{% for structure in structures %}
<tr>
<td><center>{{ structure.name }}</center></td>
<td><center>{{ structure.created_at }}</center></td>
<td><center>{{ structure.updated_at }}</center></td>
<td><center>{{ structure.file }}</center></td>
<td>
<a href="/edit/{{ structure.id }}" class="btn btn-primary btn-xs">Edit</a>
<a href="/delete/{{ structure.id }}" class="btn btn-danger btn-xs">Delete</a>
</td>
</tr>
{% endfor %}
</tbody>
Any thoughts on why the dropdown menu isn't displaying correctly? Thanks!