From 21be9fef7b14edd75c6ee402ec2bb28bf9b6ce59 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Sun, 11 Aug 2013 00:01:30 +0100 Subject: [PATCH] Stop being overcautious about Field.rel --- django/db/backends/schema.py | 4 ++-- django/db/migrations/autodetector.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/django/db/backends/schema.py b/django/db/backends/schema.py index 191e72c53a..1e1376a4e2 100644 --- a/django/db/backends/schema.py +++ b/django/db/backends/schema.py @@ -437,7 +437,7 @@ class BaseDatabaseSchemaEditor(object): } ) # Drop any FK constraints, we'll remake them later - if getattr(old_field, "rel"): + if old_field.rel: fk_names = self._constraint_names(model, [old_field.column], foreign_key=True) if strict and len(fk_names) != 1: raise ValueError("Found wrong number (%s) of foreign key constraints for %s.%s" % ( @@ -584,7 +584,7 @@ class BaseDatabaseSchemaEditor(object): } ) # Does it have a foreign key? - if getattr(new_field, "rel"): + if new_field.rel: self.execute( self.sql_create_fk % { "table": self.quote_name(model._meta.db_table), diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py index ff5957fe7e..2771bcbc68 100644 --- a/django/db/migrations/autodetector.py +++ b/django/db/migrations/autodetector.py @@ -46,8 +46,8 @@ class MigrationAutodetector(object): # Are there any relationships out from this model? if so, punt it to the next phase. related_fields = [] for field in new_app_cache.get_model(app_label, model_name)._meta.fields: - if hasattr(field, "rel"): - if hasattr(field.rel, "to"): + if field.rel: + if field.rel.to: related_fields.append((field.name, field.rel.to._meta.app_label.lower(), field.rel.to._meta.object_name.lower())) if hasattr(field.rel, "through") and not field.rel.though._meta.auto_created: related_fields.append((field.name, field.rel.through._meta.app_label.lower(), field.rel.through._meta.object_name.lower()))