[Answered ]-Adding namespaced attribute to django-crispy-form field

1👍

You can achieve this by passing the keyword argument in a dictionary, and expanding that into the kwargs for Field using the ** unpacking operator:

Field('model', **{"x-bind:disable": "disableInput"})

This gets around the fact that you can’t use dashes and colons in Python variable names. The attribute will be rendered as:

<input ... x-bind:disable="disableInput">

Leave a comment