How do I specify an id for a fieldset in crispy-forms

747 Views Asked by At

I have a django crispy form. Everything is in order, however, I would like to specify an id for it instead of having it autogenerate for me. Is there a way to accomplish this?

I have read the documentation and scoured the internet for sometime, but have not had any luck.

Any help would be appreciated.

2

There are 2 best solutions below

0
On BEST ANSWER

I found it. There is a kwarg id that can be applied to the invocation of the crispy form.

0
On

I ran into this same question. Here is how I solved it per redcloud1800's initial post:

Fieldset(
  'Registration Goal',
  'registration_goal',
  id = 'registration_goal_field'
),

The id kwarg in Fieldset adds that id to the HTML tag like: <fieldset id='registration_goal_field'>