It looks like your problem is that you have a ForeignKey pointing both
ways... This is unnecessary. You only need one ForeignKey, pointing from the
pointing from the 'child' to the 'parent'... I would guess from your
snippet, that one employee can have many contracts and assignments so you
need to delete these 2 lines:
employee_contract = models.ForeignKey('EmployeeContract')
employee_assignment = models.ForeignKey('EmployeeAssignment')
Django ORM will add two properties to your model which will return a query
set of all of an individual Employee's contracts or assignments. These
properties (they're actually descriptors) will be called something like
employeecontract_set, if you want to change this name put:
employee = models.ForeignKey(Employee, related_name='contracts')
or whatever you want to call the relationship... now you'll be able to do:
>>> emp = Employee.objects.get(<lookup_parameters>)
>>> emp.contracts.all()
... [<EmployeeContract: ....>...... ]
Hope this explains it OK.
Ben
On 30/07/07, James Bennett <[EMAIL PROTECTED]> wrote:
>
>
> On 7/29/07, james_027 <[EMAIL PROTECTED]> wrote:
> > D:\private\james\documents\django\ksk>python manage.py validate
> > manning.employee: Reverse query name for field 'employee_contract'
> > clashes with field 'EmployeeContr
> > act.employee'. Add a related_name argument to the definition for
> > 'employee_contract'.
> > manning.employee: Reverse query name for field 'employee_assignment'
> > clashes with field 'EmployeeAss
> > ignment.employee'. Add a related_name argument to the definition for
> > 'employee_assignment'.
> > 2 errors found.
>
> Django is telling you exactly what you need to do to resolve the
> error. Look at the model documentation for "related_name" for more
> details.
>
>
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of
> correct."
>
> >
>
--
Regards,
Ben Ford
[EMAIL PROTECTED]
+628111880346
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---