[Answer]-Django inlineformset extra lines being ignored

1👍

In your view you have a single IndicatorForm for a single Indicator instance, along with a DiseaseFormSet to bind multiple Disease instances to that single Indicator. Yet in your models.py you have a ForeignKey from Indicator to Disease, meaning that an Indicator can only be bound to one single Disease instance, while a Disease instance can have as many Indicators as you want.

To fix it, change the ForeignKey from being in the Indicator model to the Disease model, to being in the Disease model to the Indicator model – or if you want it the other way around, stick with the models you’ve got and use an IndicatorFormSet with a single DiseaseForm.

👤knbk

Leave a comment