modern-doctor-63477
03/16/2022, 10:48 PMmodern-doctor-63477
03/17/2022, 12:23 AMblue-gold-89534
03/21/2022, 10:05 AMfresh-judge-74869
03/21/2022, 10:56 PM{% render_field form.test_lab hx-get="/orders/test_lab/unit_quantity_price/" hx-swap="outerHTML" hx-target="#id_order_items-{{ forloop.counter0 }}-price" %}
but this is not working hx-target="#id_order_items-{{ forloop.counter0 }}-price"
cos I'm trying to render an inline_formset_factory and try to target each itemfresh-judge-74869
03/21/2022, 10:59 PM<select name="order_items-{{ forloop.counter0 }}-test_lab" hx-swap="outerHTML"
hx-target="#id_order_items-{{ forloop.counter0 }}-price"
x-get="/orders/test_lab/unit_quantity_price/" class="form-control chained-fk"
id="id_order_items-{{ forloop.counter0 }}-test_lab"
data-chainfield="order_items-{{ forloop.counter0 }}-characteristictestlab"
data-url="/chaining/filter/tests_labs/TestLab/characteristic/orders/OrderItem/test_lab"
data-value="null" data-auto_choose="false" data-empty_label="--------">
{% for value, key in form.test_lab.choices %}
<option value="{{ value }}" {% if form.initial.test_lab == value %} selected {% endif %}>
{{ key }}
</option>
{% endfor %}
</select>
but is not optimal does anyone knows how to add an iterate attribute inside the render_field of widget-tweaks to add an htmx attribute?hundreds-camera-24900
03/22/2022, 12:02 AMfresh-judge-74869
03/22/2022, 12:18 AMhundreds-camera-24900
03/22/2022, 12:19 AMhundreds-camera-24900
03/22/2022, 12:19 AMhundreds-camera-24900
03/22/2022, 12:19 AMfresh-judge-74869
03/22/2022, 12:28 AMhundreds-camera-24900
03/22/2022, 12:29 AMfresh-judge-74869
03/22/2022, 1:55 AMhundreds-camera-24900
03/22/2022, 2:01 AMhundreds-camera-24900
03/22/2022, 2:01 AMfresh-judge-74869
03/22/2022, 3:15 PM{% for u in formset.forms %}
{% render_field u.name hx-target="name-{{forloop.counter0}}" %}
{% endfor %}
blue-gold-89534
03/22/2022, 8:53 PMblue-gold-89534
03/22/2022, 8:56 PMblue-gold-89534
03/22/2022, 8:56 PMfresh-judge-74869
03/22/2022, 10:37 PM{% with hxtarget=forloop.counter0 %}
{% render_field form.test_lab class="form-control" hx-taget=hxtarget %}
{% endwith %}
gorgeous-airport-54386
03/22/2022, 10:38 PM{% render_field u.name hx-target="name-" + forloop.counter0 %}
fresh-judge-74869
03/22/2022, 10:57 PM'render_field' tag requires a form field followed by a list of attributes and values in the form attr="value": +
fresh-judge-74869
03/22/2022, 11:58 PM{% with hxtarget="#id_order_items-"|add:forloop.counter0|add:"-price"%}
{% render_field form.test_lab hx-target=hxtarget %}
{% endwith %}
Does anyone knows why the output of the render field is hx-target="-price" and the forloop.counter0 is not working?fresh-controller-36545
03/23/2022, 8:56 AMfresh-controller-36545
03/23/2022, 8:57 AM{{ form.field.auto_id }}
instead.fresh-judge-74869
03/23/2022, 3:35 PMapp/templatetags/extra_tagas.py 👈🏾 create a simple tag two add two strings (StackOverflow search)
from django import template
register = template.Library()
@register.filter(name=addstr)
def addstr(arg1, arg2):
"""concatenate arg1 & arg2"""
return str(arg1) + str(arg2)
inside the form 👈🏾 **{% with hxtarget="#id_order_items-"|addstr:forloop.counter0|addstr:"-price" %}** so you can pass to the render_field **hx-target=hxtarget**
{% with hxtarget="#id_order_items-"|addstr:forloop.counter0|addstr:"-price" %}
{% render_field form.test_lab hx-target=hxtarget class="form-control" hx-swap="outerHTML" hx-get="/orders/test_lab/unit_quantity_price/" %}
{% endwith %}
thanksplain-kangaroo-26043
03/24/2022, 7:54 PMplain-kangaroo-26043
03/24/2022, 7:54 PMplain-kangaroo-26043
03/24/2022, 7:55 PMeager-lighter-51415
04/06/2022, 4:41 PM