From 0f54cf28c09a80254571487e3af93be2096cfdac Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Thu, 5 Feb 2015 16:13:57 -0500 Subject: [PATCH] Added UUIDField.deconstruct() --- django/db/models/fields/__init__.py | 5 +++++ tests/model_fields/test_uuid.py | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 7c0358e74fb..5e11a47a684 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -2366,6 +2366,11 @@ class UUIDField(Field): kwargs['max_length'] = 32 super(UUIDField, self).__init__(**kwargs) + def deconstruct(self): + name, path, args, kwargs = super(UUIDField, self).deconstruct() + del kwargs['max_length'] + return name, path, args, kwargs + def get_internal_type(self): return "UUIDField" diff --git a/tests/model_fields/test_uuid.py b/tests/model_fields/test_uuid.py index 13fe245be31..d2ffe71a3ac 100644 --- a/tests/model_fields/test_uuid.py +++ b/tests/model_fields/test_uuid.py @@ -35,6 +35,14 @@ class TestSaveLoad(TestCase): self.assertEqual(loaded.field, None) +class TestMigrations(TestCase): + + def test_deconstruct(self): + field = models.UUIDField() + name, path, args, kwargs = field.deconstruct() + self.assertEqual(kwargs, {}) + + class TestQuerying(TestCase): def setUp(self): self.objs = [