Commit 21be9fef authored by Andrew Godwin's avatar Andrew Godwin
Browse files

Stop being overcautious about Field.rel

parent 77028194
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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),
+2 −2
Original line number Diff line number Diff line
@@ -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()))