Create model for schema of csv file

I need to create model for schema which consists of name and columns. Users can build the data schema with any number of columns of any type. Each column also has its own name (which will be a column header in the CSV file), type and order (just a number to manage column order).

The problem is that I have to create schema at one time with columns, but I don't know how to do this.

My current models:

SCHEMA_TYPE_CHOICE = (
    ('Full Name', 'Full Name'),
    ('Job', 'Job'),
    ('Email', 'Email'),
    ('Company', 'Company'),
    ('Phone Number', 'Phone Number'),
    ('Address', 'Address'),
    ('Date', 'Date'),
)


class Schema(models.Model):
    title = models.CharField(max_length=100, unique=True)
    updated_at = models.DateTimeField(auto_now=True)
    created_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.title


class Column(models.Model):
    name = models.CharField(max_length=100)
    type = models.CharField(max_length=100, choices=SCHEMA_TYPE_CHOICE, default='Full Name')
    order = models.PositiveIntegerField(default=1)
    schema = models.ForeignKey(Schema, on_delete=models.CASCADE, related_name='column_schema')

    def __str__(self):
        return self.name

Form that I have to realize: enter image description here

Back to Top