Optional tag with data- * attributes in Django with crispy shapes

I have a field ModelMultipleChoiceFielthat does something like this

<select multiple="multiple">
  <option pk="1">something 1</option>
  <option pk="2">something 2</option>
</select>

But I would like to add additional parameters data-*to the parameters, so I want the rendered HTML to look something like this.

<select multiple="multiple">
  <option pk="1" data-something-from-model="cat">something 1</option>
  <option pk="2" data-something-from-model="dog">something 2</option>
</select>

Is there a way to do this with crispy shapes? If not, where should I look for the source code?

(I'm currently doing it like Field("networks", css_class="form-control"))

+4
source share

Source: https://habr.com/ru/post/1524098/


All Articles