mirror of
https://github.com/django/django.git
synced 2024-12-25 02:26:12 +00:00
Stop being overcautious about Field.rel
This commit is contained in:
parent
7702819441
commit
21be9fef7b
@ -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),
|
||||
|
@ -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()))
|
||||
|
Loading…
Reference in New Issue
Block a user