From 2faeb21d2f618d5bfe9f8f6c574730d3f9407b2a Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Fri, 24 Nov 2017 03:05:40 -0500 Subject: [PATCH] Moved _get_model_tuple() to the base Operation class. This allows field and special operations to use this logic. --- django/db/migrations/operations/base.py | 9 +++++++++ django/db/migrations/operations/models.py | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) 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()