Ahh, yes, those docs assume you've also read the non-model formset docs:
https://docs.djangoproject.com/en/1.7/topics/forms/formsets/

Why do I get 3 "Implementation" forms, instead of just 1, when I did 
> Controls.objects.get(pk=1), which should specify a single Control? 

It will show one form for each implementation already in the database, 
plus, by default, one "extra" blank form for adding an additional 
implementation for that control.

How do I display multiple Implementation Forms for each Control that is 
> returned?

Formsets are for handling an arbitrary number of forms, and it sounds like 
you want _multiple_ _formsets_.

How do I only display certain elements of the Implementation form, not 
> every field in the model as an HTML <input> field?

Pass in "fields" to your factory call.
https://docs.djangoproject.com/en/1.7/topics/forms/modelforms/#modelform-factory-function

How do I have my views.py interpret the submitted Implementation form data 
> from the user?

I think your case is pretty complicated. Does this seem right?

ControlImplementationSet = inlineformset_factory(Controls, Implementation, 
fields=['implementation', 'status'])

def the_view(request):
    controls = Controls.objects.all()
    controlsets = []
    if request.method == 'POST':  # handling submitted data
        all_valid = True
        for control in controls:
            formset = ControlImplementationSet(request.POST, instance=
control, prefix='control_%s' % control.pk)
            if not formset.is_valid():
                all_valid = False
            controlsets.append(formset)
        if all_valid:
            for formset in controlsets:
                formset.save()
            return redirect('/success!/')
    else:  # displaying the forms the first time
        for control in controls:
            formset = ControlImplementationSet(instance=control, prefix=
'control_%s' % control.pk)
            controlsets.append(formset)
    return render(request, 'the_template.html', {'controlsets': controlsets
})

Then, in your template:
{% for formset in controlsets %}

Control Name: {{ formset.instance.name }}
Control Description: {{ formset.instance.description }}

{% for form in formset %}  {# multiple forms per control #}
Implementation Statement: {{ form.implementation }}
Implementation Status: {{ form.status }}
{% endform %}

{% endfor %}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7db396d5-3302-4500-a37d-709e5e923475%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to