[Answer]-Django get_or_create fails on models.ForeignKey fails

1👍

Try:

company = Company.objects.get(id=company_id)

employee, created = Employee.objects.get_or_create(name=emp_name, phone_number=emp_phone_number,company=company)
employee.save()

Leave a comment