Django FormSets

i need to create a parent child model forms that would save data like this.

class Company(models.Model):
   name = models.CharField(max_length=100)
   vatin = models.CharField(max_length=100)

class Employee(forms.Form):
    first_name = forms.CharField(max_length=100)
    last_name = forms.CharField(max_length=100)
    company = models.ForeignKey(Company)

I need the Company to Submit their name and vatin in a form and add any number of employees. ( formset_factory ? )
Than i need to print the company and all of their employees and one employee and his company.
Any idea how to do this?

How much experience do you have with Django at this point? Have you worked through one or more of the tutorials?
You mention the idea of adding “any number of employees” - that implies dynamically altering a formset via JavaScript. What’s your level of comfort with that?

Are you talking about actual print (as in generating a list on paper), or are you talking about generating a page with this list?

1 Like

I am pretty much a beginner to Django and followed a few tutorials on youtube.

I am building the ecommerce via Django and Vue.js so i could cycle the employee form based on the variable, where the company selects the number of employees, right?

I need to create in an admin page an overview of the order that would go like this:
Company1: Employee1, Employee2, Employee3
Company1: Employee2
Company1: Employee3

Thanks for your interest in helping me. I’d be more than thankful if we could manage a call and try to figure this out. :slightly_smiling_face:

I’m sorry, I’m not available for private consultations.

What I might suggest is that you find a consulting firm to contract with to get the level of detailed assistance you may need.