style: use prefetched queryset length in card_gallery template

This commit is contained in:
Stephan Kerkman 2026-05-28 21:57:57 +02:00
parent 39de3983f1
commit 52acd9e1f1

View file

@ -19,9 +19,8 @@
{% endfor %} {% endfor %}
</div> </div>
{% endif %} {% endif %}
{% endwith %}
{% if plant.card_photos.count < 3 %} {% if card_photos|length < 3 %}
<form method="post" action="{% url 'upload_card_photo' plant.pk %}" enctype="multipart/form-data" <form method="post" action="{% url 'upload_card_photo' plant.pk %}" enctype="multipart/form-data"
hx-post="{% url 'upload_card_photo' plant.pk %}" hx-target="#card-gallery" hx-swap="outerHTML" hx-post="{% url 'upload_card_photo' plant.pk %}" hx-target="#card-gallery" hx-swap="outerHTML"
hx-encoding="multipart/form-data"> hx-encoding="multipart/form-data">
@ -32,6 +31,7 @@
<button type="submit" class="btn btn-sm btn-outline-secondary">Upload</button> <button type="submit" class="btn btn-sm btn-outline-secondary">Upload</button>
</div> </div>
</form> </form>
{% endif %}
<small class="text-muted">Up to 3 photos — front &amp; back of the label</small> <small class="text-muted">Up to 3 photos — front &amp; back of the label</small>
{% endif %}
{% endwith %}
</div> </div>