Skip to content

Instantly share code, notes, and snippets.

@douglasmiranda
Created September 10, 2024 02:29
Show Gist options
  • Save douglasmiranda/0a116adb06a2d801623fc22cc44dc4ed to your computer and use it in GitHub Desktop.
Save douglasmiranda/0a116adb06a2d801623fc22cc44dc4ed to your computer and use it in GitHub Desktop.
Django BaseInlineFormset custom attributes to DELETE button
class ScheduleInlineFormSet(BaseInlineFormSet):
def add_fields(self, form, index):
super().add_fields(form, index)
# customizing for bootstrap needs
if "DELETE" in form.fields:
form.fields["DELETE"] = forms.BooleanField(
label="Excluir",
widget=forms.CheckboxInput(attrs={"class": "btn-check"}),
required=False,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment