Preparing and saving inline strings in django-extra-views

I am using django-extra-views, and I wanted to fill out a form and its associated rows with pre-populated data, and then save (create an object). So far, I:

from extra_views import CreateWithInlinesView class ItemCreateView(extra_views.CreateWithInlinesView): def dispatch(self, request, item_pk, *args, **kwargs): self.item = models.Item.objects.get(id=item_pk) return super(ItemCreateView, self).dispatch( request, *args, **kwargs ) def get_initial(self): # Thanks to that method a form is populated with initial data. return forms.ItemCreateForm(instance=self.item).initial def construct_inlines(self): # Thanks to that method a form and its inlines are prepopulated successfully. ItemFormSet = inlineformset_factory(models.Item, models.ItemEntry, extra=0) formset = ItemFormSet(instance=self.item) return [formset] 

However, the object is saved without inline strings, even though the values ​​in the strings are passed through POST. What am I doing wrong? Should I initialize the form and embed another way?

+5
source share

Source: https://habr.com/ru/post/1200617/


All Articles