Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

129
Views
Django crispy form with formset does not show delete checkbox

I have some code structure very similar to this example: https://gist.github.com/ibarovic/3092910

Everything is working pretty well, except that the delete checkbox after each Book element is not shown at all. If I change

{% crispy formset formset.form.helper %}

to

{% crispy formset %}

the delete checkboxes are shown, but the form does not work anymore (b/c the HTML form tags are used not only once).

I suspect that those checkboxes are not known to the BookForm (b/c they somehow get added later by the inlineformset_factory), so they do not get added to the layout and are ignored. I have no idea how to circumvent that though.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I found a solution thanks to this: Django crispy-forms, BaseGenericInlineFormSet & allow_delete

In the BookForm (which gets repeated many times) init, you can add something like:

self.helper = FormHelper(form=self) # or manual layout
self.helper.form_tag = False

i = self.helper.layout.fields.index('title')
self.helper.layout.insert(i+1, layout.Field("DELETE"))

The capital letters "DELETE" field then gets added to each single BookForm...

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!