Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Stop being overcautious about Field.rel

  • Loading branch information...
commit 21be9fef7b14edd75c6ee402ec2bb28bf9b6ce59 1 parent 7702819
@andrewgodwin andrewgodwin authored
View
4 django/db/backends/schema.py
@@ -437,7 +437,7 @@ def alter_field(self, model, old_field, new_field, strict=False):
}
)
# 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 @@ def alter_field(self, model, old_field, new_field, strict=False):
}
)
# 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),
View
4 django/db/migrations/autodetector.py
@@ -46,8 +46,8 @@ def changes(self):
# 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()))
Please sign in to comment.
Something went wrong with that request. Please try again.