I have a model called Employee which is defined as follows:
class Employee(models.Model):
created = models.DateTimeField(auto_now_add=True)
name = models.CharField("Name", max_length=255)
address = models.CharField("Address", max_length=255)
department = models.ForeignKey(Department, on_delete=models.SET_NULL)
team = models.ForeignKey(Team, on_delete=models.SET_NULL)
position = models.ForeignKey(Position, on_delete=models.SET_NULL)
Is there a way to add multiple name and address of employee for the same department, team and position in django-admin form? I want something like formset including fields name and address for the model Employee where you can enter the department, team and postion and just add the formsets multiple times like how you would do for inlines.
I have not tried anything as of yet.
you can do this in Django admin by using inline formsets. In your case, you want to allow multiple name and address entries for the same department, team, and position in the Django admin form.