{% load crispy_forms_tags %}
<form  method="post" enctype="multipart/form-data">
    <div class='row'>
        <div class="col-md-9">
    {% csrf_token %}
    {% for f in form %}
        {% if sideFields %}
            {% if f not in sideFields %}
                {{ f | as_crispy_field  }}
            {% endif %}
        {% else %}
            {{ f | as_crispy_field  }}
        {% endif %}
    {% endfor %}
    <!--
        {{ form | crispy  }} -->
    {% if orderFormset %}
        {{ orderFormset.management_form }}
        <table class='table table-bordered table-striped'>

            

                {% for f in orderFormset %}
                <tr>
                    {% for f0 in f.visible_fields %}
                    <td>{{ f0  | as_crispy_field}}</td>
                    {% endfor %}

                    {% for f0 in f.hidden_fields %}
                    {{ f0  | as_crispy_field}}
                    {% endfor %}
                </tr>
                {% endfor %}
            </tbody>
        </table>
    {% endif %}
    {% if menuItemFormset %}
        {{ menuItemFormset.management_form }}
        <table class='table table-bordered table-striped'>
            <tbody>

                {% for f in menuItemFormset %}
                <tr>
                    {% for f0 in f.visible_fields %}
                    <td>{{ f0  | as_crispy_field}}</td>
                    {% endfor %}

                    {% for f0 in f.hidden_fields %}
                    {{ f0  | as_crispy_field}}
                    {% endfor %}
                </tr>
                {% endfor %}
            </tbody>
        </table>
    {% endif %}
    {% if formset %}
        {{ formset.management_form }}
        <table class='table table-bordered table-striped'>
            <tbody>

                {% for f in formset %}
                <tr>
                    {% for f0 in f.visible_fields %}
                    <td>{{ f0  | as_crispy_field}}</td>
                    {% endfor %}

                    {% for f0 in f.hidden_fields %}
                    {{ f0  | as_crispy_field}}
                    {% endfor %}
                </tr>
                {% endfor %}
            </tbody>
        </table>
    {% endif %}
    {% if formsets %}
        {% if vert == True %}
            {% for k, formset in formsets.items %}
                <h2>{{ k }}</h2>
                {{ formset | crispy }}
            {% endfor %}
        {% else %}
            {% for k, formset in formsets.items %}
                <h2>{{ k }}</h2>
                {{ formset.management_form }}
                <table class='table table-bordered table-striped'>
                    <tbody>

                        {% for f in formset %}
                        <tr>
                            {% for f0 in f.visible_fields %}
                            <td>{{ f0  | as_crispy_field}}</td>
                            {% endfor %}

                            {% for f0 in f.hidden_fields %}
                            {{ f0  | as_crispy_field}}
                            {% endfor %}
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            {% endfor %}
        {% endif %}
    {% endif %}
    <input type="submit" class='btn btn-primary' name='save' value="Save">
    {% if obj and not disableDelete%}
    <input type='submit' class='btn btn-danger' value='Delete' name='delete'>
    {% endif %}
        </div>
        <div class='col-md-3'>
            {{ form.instance.qrImage }}
            <br/>
            {% for f in sideFields %}
                {{ f | as_crispy_field  }}
            {% endfor %}
    <input type="submit" class='btn btn-primary' name='save' value="Save">
    {% if obj and not disableDelete%}
    <input type='submit' class='btn btn-danger' value='Delete' name='delete'>
    {% endif %}
        </div>
    </div>
</form>
