Posts

Showing posts from May, 2023

django inline formset id: * this field is required.

By default  django-crispy-forms   renders the layout specified if it exists strictly. Sometimes you might be interested in rendering all form’s hidden fields no matter if they are mentioned or not. So we get an error like: formset id: * this field is required. We can set render_hidden_fields an attribute of Form Helper to True. from crispy_forms.helper import FormHelper class FormHelperWithHiddenFields ( FormHelper ): form_tag = False field_class = "mb-4" # Required to render hidden fields to prevent >id: this field is required. render_hidden_fields = True Useful when trying to render forms with layouts as part of a formset with hidden primary key fields.