[Fixed]-Django: How do I create a view to update multiple records on an intermediate model with a Many-to-Many-through relationship?

1๐Ÿ‘

โœ…

I think I have this mostly working now with Django-Extra-Views.
My view looks like this:

class GuestEventInline(InlineFormSet):
    model = GuestEvent
    fields = [ 'attending', 'adults', 'children' ]
    extra = 0
    can_delete=False

class Invite2View(UpdateWithInlinesView):
    template_name = "weddings/invite2.html"
    model = Guest
    inlines = [ GuestEventInline ]

And my template looks like this:

<form action="" method="post" class="form-horizontal">
    {% csrf_token %}
    {{ form }}        
    {% for formset in inlines %}
        {{ formset.id }}
        {{ formset.management_form}}
        {%for subform in formset%}
            <h4>{{ subform.instance.event }}</h4></a>
            {{ subform.as_p }}
        {% endfor %}
    {% endfor %}
    {% buttons submit='Save' %}{% endbuttons %}
</form>
๐Ÿ‘คRedleader36

Leave a comment