I have difficulty using two cartilaginous forms of django at the same time. I have one form to simply enter new data into my application and another form that appears in the bootstrap module for users to provide feedback. Below I have stripped my template to bare basics.
I have a group form:
class Crispy_Group_Form(forms.ModelForm): def __init__(self, *args, **kwargs): self.helper = FormHelper()
and contact form
class Crispy_ContactForm(forms.ModelForm): def __init__(self, *args, **kwargs): self.helper = FormHelper() self.helper.form_class = 'form ajax' self.helper.form_action = 'feedback' self.helper.form_tag = False self.helper.layout = Layout( Fieldset( 'Contact Form', Field('topic', placeholder='Topic', css_class='input-medium'), Field('subject', placeholder='Subject', css_class='input-xlarge'), Field('message', placeholder='Message', rows='5', css_class='input-xlarge'), Field('sender', placeholder='Sender', css_class='input-xlarge'), ), ) self.helper.form_id = 'id-Crispy_ContactForm' self.helper.form_method = 'post' super(Crispy_ContactForm, self).__init__(*args, **kwargs) class Meta: model = Feedback exclude = ['creation_date']
My opinion:
def bootstrap_test(request): return render_to_response( "bootstrap_test.html", { 'feedback_form' : Crispy_ContactForm, 'form' : Crispy_Group_Form, }, context_instance=RequestContext(request))
And my simplest template:
{% load crispy_forms_tags %} <form action="{% url feedback %}" method="post" id="id-Crispy_ContactForm" class="form"> {% crispy feedback_form %} </form> {% crispy form %}
The feedback form is displayed twice. As if both forms have the same shape. If I remove the feedback form from the template, it will display the group form. If I regroup them so that {% crispy form%} is higher than reverse_selection, it displays two different forms correctly.
I read the documentation but could not find a way that works.
Why is this happening and what do I need to configure so that it displays correctly?