python django: error using inline formset
<p>I have the following models:</p>
<pre><code>class Equipment(models.Model):
    asset_number = models.CharField(max_length = 200)
    serial_number = models.CharField(max_length = 200)

class Calibration(models.Model):
    cal_asset = models.ForeignKey(Equipment, on_delete = models.CASCADE)
    cal_by = models.CharField(max_length = 200)
    cal_date = models.DateField()
    notes = models.TextField(max_length = 200)
</code></pre>
<p>and view:</p>
<pre><code>def default_detail (request, equipment_id):
    equipment = Equipment.objects.get(id = equipment_id)
    if request.method == &quot;POST&quot;:
        if 'calibration' in request.POST:
            EquipmentInlineFormSet = inlineformset_factory(Equipment, Calibration, fields = ('cal_by', 'cal_dates', 'notes')
            formset = EquipmentInlineFormSet(request.POST, request.FILES, instance=equipment)
            if formset.is_valid():
                formset.save()
            return HttpResponseRedirect(reverse('calbase:default_detail', args=(post.id)))
    else:
        formset = EquipmentInlineFormSet(instance=equipment)
    return render(request, 'calbase/default_detail.html', {'formset' : formset})
</code></pre>
<p>and template for this view:</p>
<pre><code>&lt;h1&gt;{{ equipment.serial_number }}&lt;/h1&gt;

{{equipment.serial_number}} -- {{equipment.asset_number}} &lt;br&gt;


calibration history:
{% for calibrations in equipment.calibration_set.all %}
&lt;ul&gt;
     &lt;li&gt;
         {{calibrations.cal_by}} -- {{calibrations.cal_date}} -- {{calibrations.notes}}
     &lt;/li&gt;
&lt;/ul&gt;
{% endfor %}

{% if error_message %}&lt;p&gt;&lt;strong&gt;{{ error_message }}&lt;/strong&gt;&lt;/p&gt;{% endif %}

&lt;form method=&quot;POST&quot; action = &quot;{% url 'calbase:default_detail' equipment.id %}&quot;&gt;{% csrf_token %}
    {{ formset }}
    &lt;button type=&quot;submit&quot; class=&quot;save btn btn-default&quot; name = &quot;calibration&quot;&gt;Save&lt;/button&gt;
&lt;/form&gt;

&lt;a href=&quot;{% url 'calbase:default' %}&quot;&gt;Back?&lt;/a&gt;
</code></pre>
<p>This view is simply a detail view of equipment, showing some information (asset and serial # of this piece of equipment). I am trying to add a formset that let user add calibration record to this equipment in this view and display them if any. I learned that using inline formset is probably the way to go. However, after following <a href="https://docs.djangoproject.com/en/1.10/topics/forms/modelforms/#using-an-inline-formset-in-a-view" rel="nofollow noreferrer">documentation</a> step by step, I am having a</p>
<blockquote>
<p>equipmentInlineFormSet = EquipmentInlineFormSet(request.POST, request.FILES, instance=equipment)</p>
<p>SyntaxError: invalid syntax</p>
</blockquote>
<p>error even though I checked to make sure that there is no typos or so. I am just trying to figure out what I did wrong here.</p>