From 5ca5178a7877cdc9cca875e24ea391dced7c6dce Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Sat, 4 Apr 2020 00:37:18 -0400 Subject: [PATCH] Replaced Operation._get_model_tuple() by ModelTuple.from_model(). This method predated the introduction of ModelTuple and had a single use. --- django/db/migrations/operations/base.py | 9 --------- django/db/migrations/operations/fields.py | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/django/db/migrations/operations/base.py b/django/db/migrations/operations/base.py index 1f5665433c6..35fdd723106 100644 --- a/django/db/migrations/operations/base.py +++ b/django/db/migrations/operations/base.py @@ -1,5 +1,4 @@ from django.db import router -from django.db.models.fields.related import RECURSIVE_RELATIONSHIP_CONSTANT class Operation: @@ -125,14 +124,6 @@ class Operation: return [self] return False - def _get_model_tuple(self, remote_model, app_label, model_name): - if remote_model == RECURSIVE_RELATIONSHIP_CONSTANT: - return app_label, model_name.lower() - elif '.' in remote_model: - return tuple(remote_model.lower().split('.')) - else: - return app_label, remote_model.lower() - def __repr__(self): return "<%s %s%s>" % ( self.__class__.__name__, diff --git a/django/db/migrations/operations/fields.py b/django/db/migrations/operations/fields.py index 1acb2edbd1e..8bde081a87f 100644 --- a/django/db/migrations/operations/fields.py +++ b/django/db/migrations/operations/fields.py @@ -339,7 +339,7 @@ class RenameField(FieldOperation): for index, (name, field) in enumerate(model_state.fields): remote_field = field.remote_field if remote_field: - remote_model_tuple = self._get_model_tuple( + remote_model_tuple = ModelTuple.from_model( remote_field.model, model_app_label, model_name ) if remote_model_tuple == model_tuple: