Reputation: 275
I have following prototype:
And following djnago classes:
class Container(models.Model):
pass
class AbstractItem(Models.model):
container = models.ForeignKey('Container')
class Meta:
abstract = True
class Item1(AbstractItem):
foo = models.CharField()
class Item2(AbstractItem):
bar = models.IntegerField()
After a successful form submission, server should parse muliple forms (or one forms union), create multiple Item instanses and refer them to container instanse.
How to perform it in Django?
Thanks.
Upvotes: 0
Views: 119
Reputation: 599470
You want a formset.
See the intro to formsets, and the docs specifically for model formsets.
Upvotes: 1