0

I have a model with default values defined. When a model is created as an inline in the administration backend and the default values remain unchanged, the model doesn't save, but if any field is altered, then the model will save.

I havent overridden any save or clean methods on the model or form.

Is this expected behavior?

skzryzg
  • 1,020
  • 8
  • 25

1 Answers1

0

The problem here is that Django is trying to see which inlines you actually want to save. As the docs put it: "The formset is smart enough to ignore extra forms that were not changed." So if you use all default values it thinks you're not using those inlines.

You could try using empty_permitted as described in this answer, although I don't think it's officially documented. You'll also have to be careful that the initial formset only includes (via extra) the minimum number of inlines you require.

Community
  • 1
  • 1
Kevin Christopher Henry
  • 46,175
  • 7
  • 116
  • 102