Consider two models:
Contract
class Contract(models.Model):
employee = models.OneToOneField(Employee, on_delete=models.CASCADE)
contract_type = models.ForeignKey(ContractType, on_delete=models.CASCADE)
start_date = models.DateField()
end_date = models.DateField()
and
Employee
class Employee(models.Model):
first_name = models.CharField(max_length=20)
last_name = models.CharField(max_length=20)
contract = models.OneToOneField(Contract, on_delete=models.CASCADE, null=True, blank=True)
I was wondering if there's a way to add temporary fields in a model form that are only shown upon creation in the Employee model so I can add all those fields while I create a new Employee then when saving, I first create an Employee object, then automatically generate a Contract object and edit the original Employee object and link the now generated Contract object.
I really hope this makes sense, and if it does, can someone guide me in the right direction?
Thank you, for your time reading this.