1

I'm working with Django forms and widget_tweaks, and I need to create an input that has html like this

<input type="text" name="designation{{ vente.id}}" value="{{ vente.designation }}" />

I've tried :

{% render_field modifier.designation class="form-control" value=vente.designation placeholder="désignation" name="designation"+vente.id %} 

I can't get the concatenated string of name, there is something with the concatenation.

PS: {{ vente.id}} is an id from my database

Thank You for your help

Elroum
  • 327
  • 1
  • 3
  • 18

1 Answers1

0

You could try to assign the "name" to a variable first, maybe using the with tag:

{% with input_name="designation"|add:vente.id %}
    {% render_field modifier.designation class="form-control"
        name=input_name value=vente.designation placeholder="désignation" %}
{% endwith %}

Otherwise you could create a input_name variable in your view and pass that to your template.

Ralf
  • 16,086
  • 4
  • 44
  • 68