Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

253
Visualizações
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.

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

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...

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda