Prepopulating and saving inlines in django-extra-views -
i'm using django-extra-views , wanted fill form , associated inlines prepopulated data , save (create object). far have:
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): # method form populated initial data. return forms.itemcreateform(instance=self.item).initial def construct_inlines(self): # method form , inlines prepopulated successfully. itemformset = inlineformset_factory(models.item, models.itementry, extra=0) formset = itemformset(instance=self.item) return [formset]
however object saved without inlines, despite fact inlines values sent via post. doing wrong? should initialize form , inlines different way?
Comments
Post a Comment