#2608: multi-level foreignkey throws KeyError
--------------------------------------------------+-------------------------
Reporter: Gopal Narayanan <[EMAIL PROTECTED]> | Owner: adrian
Type: defect | Status: new
Priority: normal | Milestone:
Component: Admin interface | Version:
Severity: minor | Keywords:
--------------------------------------------------+-------------------------
Example models:
{{{
class person(models.Model):
pid = models.CharField(maxlength=20,
primary_key=True)
name = models.CharField(maxlength=100)
class student(models.Model):
student_pid = models.ForeignKey(person,
db_column='student_pid',
to_field='pid')
class student_option(models.Model):
pid = models.ForeignKey(student,
to_field='student_pid')
junk = models.IntegerField()
}}}
Note that student_option pid refers to student_pid which itself is a
ForeignKey on student pointing to person.
Trying to generate SQL for these models throws KeyError: 'ForeignKey'
It appears that FKs are not allowed to point at a datatype that is itself
a FK. It would be nice to allow multi-level foreign keys as there is a
benefit in modeling legacy data with this kind of schema.
The patch attached simply enables the creation of SQL necessary for this
to happen, by recursively diving down until we find the real underlying
datatype.
--
Ticket URL: <http://code.djangoproject.com/ticket/2608>
Django <http://code.djangoproject.org/>
The web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" 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-updates
-~----------~----~----~----~------~----~------~--~---