mirror of https://github.com/django/django.git
Added missing logic to TimeField.deconstruct().
If auto_now or auto_now_add was used then the serialized field in the migration contained unnecessary `editable` and `blank` arguments.
This commit is contained in:
parent
72f1eb48df
commit
7432533932
|
@ -2083,6 +2083,9 @@ class TimeField(DateTimeCheckMixin, Field):
|
|||
kwargs["auto_now"] = self.auto_now
|
||||
if self.auto_now_add is not False:
|
||||
kwargs["auto_now_add"] = self.auto_now_add
|
||||
if self.auto_now or self.auto_now_add:
|
||||
del kwargs['blank']
|
||||
del kwargs['editable']
|
||||
return name, path, args, kwargs
|
||||
|
||||
def get_internal_type(self):
|
||||
|
|
|
@ -336,6 +336,23 @@ class FieldDeconstructionTests(TestCase):
|
|||
self.assertEqual(args, [])
|
||||
self.assertEqual(kwargs, {})
|
||||
|
||||
def test_time_field(self):
|
||||
field = models.TimeField()
|
||||
name, path, args, kwargs = field.deconstruct()
|
||||
self.assertEqual(path, "django.db.models.TimeField")
|
||||
self.assertEqual(args, [])
|
||||
self.assertEqual(kwargs, {})
|
||||
|
||||
field = models.TimeField(auto_now=True)
|
||||
name, path, args, kwargs = field.deconstruct()
|
||||
self.assertEqual(args, [])
|
||||
self.assertEqual(kwargs, {'auto_now': True})
|
||||
|
||||
field = models.TimeField(auto_now_add=True)
|
||||
name, path, args, kwargs = field.deconstruct()
|
||||
self.assertEqual(args, [])
|
||||
self.assertEqual(kwargs, {'auto_now_add': True})
|
||||
|
||||
def test_url_field(self):
|
||||
field = models.URLField()
|
||||
name, path, args, kwargs = field.deconstruct()
|
||||
|
|
Loading…
Reference in New Issue