Skip to content

UpdateWithInlinesView not working with crispy_forms #216

@kishalaykundu

Description

@kishalaykundu

I am using 'extra_views' to create and update a model 'Patient' and its related model 'PatientAddress'. I am also using 'crispy_forms' to beautify the html form. CreateWithInlinesView works fine. The UpdateWithInlinesView however does not seem to play nice with crispy_forms.
I have attached the requisite files, but I give a description of the problem below:

In 'update.html', I have the following lines:

DOES NOT WORK

`
{% csrf_token %}
<div class="form-row">
    <div class="form-group col-md-8 mb-0">
        {{ form.name|as_crispy_field }}
    </div>
    <div class="form-group col-md-4 mb-0">
        {{ form.phone|as_crispy_field }}
    </div>
</div>

{% for formset in inlines %} {% for addr in formset %}
<div class="form-row">
    <div class="form-group col-md-6 mb-0">
        {{ addr.line_1|as_crispy_field }}
    </div>
    <div class="form-group col-md-6 mb-0">
        {{ addr.line_2|as_crispy_field }}
    </div>
</div>

{% endfor %} {{ formset.management_form }} {% endfor %}

<div class="control-group text-right">
    <div class="controls">
        <button type="submit" class="btn btn-default btn-person"><i class="fas fa-save"></i> Save</button>
    </div>
</div>

WORKS:

`
{% csrf_token %}
<div class="form-row">
    <div class="form-group col-md-8 mb-0">
        {{ form.name|as_crispy_field }}
    </div>
    <div class="form-group col-md-4 mb-0">
        {{ form.phone|as_crispy_field }}
    </div>
</div>

{% for formset in inlines %}  {{ formset }} {% endfor %}

<div class="control-group text-right">
    <div class="controls">
        <button type="submit" class="btn btn-default btn-person"><i class="fas fa-save"></i> Save</button>
    </div>
</div>

The first form comes back to the update page whereas the second form works but is not at all aesthetically nice. I am not quite sure what to do with this or how to proceed from here. I apologize in advance if this is not the appropriate place to post about this.

code.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions