diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2010-02-22 14:04:13 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2010-02-22 14:04:13 +0000 |
| commit | e6db084ac8fdf04ba20b5976a1cebfb77d55c97e (patch) | |
| tree | 71f65cecdc2ea74c94a3e1f6c3462d7f925c9357 /django/core | |
| parent | eb67e449dde298a35664c0daea61860ac63a1f58 (diff) | |
Fixed #11226 -- Corrected an validation edge case with m2m relations between two models with the same class name. Thanks to pkoch for the report, and to Ramiro Morales for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12489 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/core')
| -rw-r--r-- | django/core/management/validation.py | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/django/core/management/validation.py b/django/core/management/validation.py index 46cdfc5c46..9b65b8ed6c 100644 --- a/django/core/management/validation.py +++ b/django/core/management/validation.py @@ -179,19 +179,20 @@ def get_validation_errors(outfile, app=None): ) else: seen_intermediary_signatures.append(signature) - seen_related_fk, seen_this_fk = False, False - for field in f.rel.through._meta.fields: - if field.rel: - if not seen_related_fk and field.rel.to == f.rel.to: - seen_related_fk = True - elif field.rel.to == cls: - seen_this_fk = True - if not seen_related_fk or not seen_this_fk: - e.add(opts, "'%s' has a manually-defined m2m relation " - "through model %s, which does not have foreign keys " - "to %s and %s" % (f.name, f.rel.through._meta.object_name, - f.rel.to._meta.object_name, cls._meta.object_name) - ) + if not f.rel.through._meta.auto_created: + seen_related_fk, seen_this_fk = False, False + for field in f.rel.through._meta.fields: + if field.rel: + if not seen_related_fk and field.rel.to == f.rel.to: + seen_related_fk = True + elif field.rel.to == cls: + seen_this_fk = True + if not seen_related_fk or not seen_this_fk: + e.add(opts, "'%s' is a manually-defined m2m relation " + "through model %s, which does not have foreign keys " + "to %s and %s" % (f.name, f.rel.through._meta.object_name, + f.rel.to._meta.object_name, cls._meta.object_name) + ) elif isinstance(f.rel.through, basestring): e.add(opts, "'%s' specifies an m2m relation through model %s, " "which has not been installed" % (f.name, f.rel.through) |
