{% extends "base.html" %} {% block title %}Inline Formset using Autocomplete{% endblock %} {% block extrahead %} {{ formset.media }} {% endblock %} {% block content %}
{{ form.as_p }}

Order details

{% for form in formset.forms %} {% endfor %}
Product Quantity
{% for fld in form.hidden_fields %}{{ fld }}{% endfor %} {% if form.instance.pk %}{{ form.DELETE }}{% endif %} {{ form.product }} {{ form.quantity }}

{{ formset.management_form }}

{% endblock %} {% block sidebar %}

This autocomplete example is supposed to show one possible use for the optional "added" and "removed" callbacks. I know it's not user-friendly to select a product name and have a strange number "magically" appear -- believe me, I wouldn't do that in production code :)

The original code I extracted this from was a bit more complicated (it allowed users specify search criteria used to create ad-hoc groups). Rather than use that, I decided to base this on the inline formset example.

{% endblock %}