Hi, I have this models ...
class Employee(models.Model): emplyoee_contract = models.ForeignKey('EmployeeContract', null=True, related_name='contracted_employee') employee_assignment = models.ForeignKey('EmployeeAssignment', null=True, related_name='assigned_employee') class EmployeeAssignment(models.Model): employee = models.ForeignKey(Employee) assignment_from = models.DateField() assignment_to = models.DateField() area = models.CharField(maxlength=3, choices=AREA_LIST) position = models.CharField(maxlength=20) edit_by = models.ForeignKey(Profile, null=True) class EmployeeContract(models.Model): employee = models.ForeignKey(Employee) contract_to = models.DateField() contract_from = models.DateField() notes = models.CharField(blank=True, maxlength=200) status = models.CharField(maxlength=3, choices=EMPLOYEE_CONTRACT_STATUS_LIST) edit_by = models.ForeignKey(Profile, null=True) and I have something like this in my view e = Employee() for key in f.cleaned_data.keys(): e.__setattr__(key, f.cleaned_data[key]) e.save() c = EmployeeContract() for key in f.cleaned_data.keys(): c.__setattr__(key, f.cleaned_data[key]) c.employee = e c.status = 'ACT' c.save() a = EmployeeAssignment() for key in f.cleaned_data.keys(): a.__setattr__(key, f.cleaned_data[key]) a.employee = e a.assignment_from = c.contract_from a.assignment_to = c.contract_to a.save() e.employee_assignment = a e.employee_contract = c e.save() all the data are valid, the problem here is that the employee.employee_contract is not get assign. everything got save successfully. here is the sql django's running {'time': '0.015', 'sql': u'INSERT INTO `manning_employee` (`lastname`,`firstname`,`middlename`,`gender`,`birthday`,`contact_no`,`address`,`notes`,`pay_by`,`hour_rate`,`allowance`,`account_no`,`sss`,`phil_health`,`pag_ibig`,`emplyoee_contract_id`,`employee_assignment_id`) VALUES (Dy,Willie,,M,1977-02-18,,Laguna,,HRR, 34.37,50.00,,,,,None,None)'}, {'time': '0.000', 'sql': u'INSERT INTO `manning_employeecontract` (`employee_id`,`contract_to`,`contract_from`,`notes`,`status`,`edit_by_id`) VALUES (13,2007-10-21,2007-03-18,,ACT,None)'}, {'time': '0.000', 'sql': u'INSERT INTO `manning_employeeassignment` (`employee_id`,`assignment_from`,`assignment_to`,`area`,`position`,`edit_by_id`) VALUES (13,2007-03-18,2007-10-21,ADM,Supervisor,None)'}, {'time': '0.000', 'sql': u'SELECT COUNT(*) FROM `manning_employee` WHERE `id`=13'}, {'time': '0.000', 'sql': u'UPDATE `manning_employee` SET `lastname`=Dy,`firstname`=Willie,`middlename`=,`gender`=M,`birthday`=1977-02-18,`contact_no`=,`address`=Laguna,`notes`=,`pay_by`=HRR,`hour_rate`=34.37,`allowance`=50.00,`account_no`=,`sss`=,`phil_health`=,`pag_ibig`=,`emplyoee_contract_id`=None,`employee_assignment_id`=10 WHERE `id`=13'}] as you can see the last update statement has employee_contract_id = None ... which I don't know what make it happen? anything wrong with my models or views? Thanks james --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---