Django crispy-forms, BaseGenericInlineFormSet & allow_delete

I came across a question while working with django-crispy forms for which I cannot get an answer. I have a rather complicated layout form, everything works very nicely with cripy forms.

One part of the form uses a common built-in set of forms. This also works, but my problem is that I cannot figure out how to access the delete-checkbox checkbox (if can_delete = True is present)

The corresponding code looks something like this:

class BaseReleaseReleationFormSet(BaseGenericInlineFormSet): def __init__(self, *args, **kwargs): self.instance = kwargs['instance'] super(BaseReleaseReleationFormSet, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_id = "id_relation_form" self.helper.form_class = 'form-horizontal' self.helper.form_method = 'post' self.helper.form_action = '' self.helper.form_tag = False base_layout = Row( Column( Field('name', css_class='input-small'), #Field('delete', css_class='input-small'), css_class='span3' ), Column( Field('url', css_class='input-xlarge'), css_class='span4' ), css_class='row relation-row', ) self.helper.add_layout(base_layout) 

The name field and url are rendered with crispy forms as desired, but the delete-check flag appears at the end of the form. And I can’t access it in the layout.

Does anyone know how to solve this problem? Any tips? Thanks in advance!

+7
source share
1 answer

Stupid I - figured it out. The delete field indicates "DELETE". (note the uppercase letters ...)

  base_layout = Row( Column( Field('name', css_class='input-small'), css_class='span3' ), Column( Field('url', css_class='input-xlarge'), Field('DELETE', css_class='input-small'), css_class='span4' ), css_class='row relation-row', ) 
+8
source

All Articles