foo
foo

Reputation: 275

Django multiple form submit

I have following prototype:

enter image description here

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

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599470

You want a formset.

See the intro to formsets, and the docs specifically for model formsets.

Upvotes: 1

Related Questions