summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2017-11-24 03:05:40 -0500
committerTim Graham <timograham@gmail.com>2017-12-30 14:50:43 -0500
commit2faeb21d2f618d5bfe9f8f6c574730d3f9407b2a (patch)
tree0a4fbed9c00f04e780ca55da8c5f318d03eae549
parent149061103829fb3ad74d050b4ae3cc815b2f451c (diff)
Moved _get_model_tuple() to the base Operation class.
This allows field and special operations to use this logic.
-rw-r--r--django/db/migrations/operations/base.py9
-rw-r--r--django/db/migrations/operations/models.py9
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()