diff --git a/django/db/migrations/operations/base.py b/django/db/migrations/operations/base.py index 6ecbfac405..3fb1002c44 100644 --- a/django/db/migrations/operations/base.py +++ b/django/db/migrations/operations/base.py @@ -1,4 +1,5 @@ from django.db import router +from django.db.models.fields.related import RECURSIVE_RELATIONSHIP_CONSTANT class Operation: @@ -124,6 +125,14 @@ 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/models.py b/django/db/migrations/operations/models.py index fcdf752f6d..857981bcb8 100644 --- a/django/db/migrations/operations/models.py +++ b/django/db/migrations/operations/models.py @@ -1,7 +1,6 @@ from django.db import models from django.db.migrations.operations.base import Operation from django.db.migrations.state import ModelState -from django.db.models.fields.related import RECURSIVE_RELATIONSHIP_CONSTANT from django.db.models.options import normalize_together from django.utils.functional import cached_property @@ -279,14 +278,6 @@ class RenameModel(ModelOperation): kwargs ) - 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 state_forwards(self, app_label, state): # Add a new model. renamed_model = state.models[app_label, self.old_name_lower].clone()