Permalink
Browse files

Fixed #2608 -- Generate correct SQL for multi-level foreign key relat…

…ions.

Based on a patch from Gopal Narayanan.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@5106 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent f30ca66 commit fb30e774f91fb91372b0a5a3e707fbbd1996da83 @malcolmt malcolmt committed Apr 27, 2007
Showing with 3 additions and 0 deletions.
  1. +1 −0 AUTHORS
  2. +2 −0 django/core/management.py
View
1 AUTHORS
@@ -164,6 +164,7 @@ answer newbie questions, and generally made Django that much better:
Robin Munn <http://www.geekforgod.com/>
Robert Myers <myer0052@gmail.com>
Nebojša Dorđević
+ Gopal Narayanan <gopastro@gmail.com>
Fraser Nevett <mail@nevett.org>
Sam Newman <http://www.magpiebrain.com/>
Neal Norwitz <nnorwitz@google.com>
View
2 django/core/management.py
@@ -168,6 +168,8 @@ def _get_sql_model_create(model, known_models=set()):
for f in opts.fields:
if isinstance(f, (models.ForeignKey, models.OneToOneField)):
rel_field = f.rel.get_related_field()
+ while isinstance(rel_field, (models.ForeignKey, models.OneToOneField)):
+ rel_field = rel_field.rel.get_related_field()
data_type = get_rel_data_type(rel_field)
else:
rel_field = f

0 comments on commit fb30e77

Please sign in to comment.