Django: save() prohibited to prevent data loss due to unsaved related object 'predictions'

True for standard initialisation, but for the initialisation of FormSets Django iterates over the num of forms and therefore it needs a list of dicts.

See here:

in my final code, this would look like such:

formset = metaFormset(data, initial=[dict(ref=obj) for x in range(int(data['form-TOTAL_FORMS']))])

No, that’s not correct - as far as this specific issue is concerned. You are not initializing the individual forms, the inline formset class is.

An inline formset uses one instance of the parent object to identify the foreign key reference.

Quoting directly from the example in the docs I referenced:

>>> formset = BookFormSet(instance=author)

Yes, but I do not talk about Inline FormSets :wink:

I’m talking about ModelForm FormSets.

I can’t reconcile this:

With this:

So are you using an inline formset (as you should in this situation), or are you not? (And if you’re not, why not?)

the line right below what you quoted…

That would then depend (in part) on the specific form being used. Is the foreign key part of the form? If so, then it would be a field in the form in the formset, and can be initialized. (But then it’s subject to being changed by the user.) If it’s not a field in the form and it can only be set within the POST handler, then you would need to save the individual forms with commit=False to get the new objects being created and update those objects before saving them.

As i notice you are trying to save formset which tied to main form.
If you are saving formset with Product which is not saved yet you can’t save formset just by using save function.
For example

#Item is main Model 
item =
item.position = 0 #Chengo position on attribute you need to specify before saving

#item_images and item_addons are formests tied by item attribute to Main model
for item_image in item_images:
     item_image =
     item_image.item = item

for item_addon in item_addons:
     item_addon =
     item_addon.item = item

Welcome @OstapTelychko ! Just a side note here: When you’re posting code in the forum, surround that code between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. This forces the forum software to keep your code properly formatted.
I’ve taken the liberty of modifying your post for this, please remember to do this yourself in the future.