summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/semantic_version/django_fields.py3
-rw-r--r--tests/test_django.py4
2 files changed, 7 insertions, 0 deletions
diff --git a/src/semantic_version/django_fields.py b/src/semantic_version/django_fields.py
index 0e1b083..d4d0042 100644
--- a/src/semantic_version/django_fields.py
+++ b/src/semantic_version/django_fields.py
@@ -26,6 +26,9 @@ class BaseSemVerField(models.CharField):
value = self.to_python(self._get_val_from_obj(obj))
return str(value)
+ def run_validators(self, value):
+ return super(BaseSemVerField, self).run_validators(str(value))
+
class VersionField(BaseSemVerField):
default_error_messages = {
diff --git a/tests/test_django.py b/tests/test_django.py
index 52d419c..3185dc3 100644
--- a/tests/test_django.py
+++ b/tests/test_django.py
@@ -54,6 +54,8 @@ class DjangoFieldTestCase(unittest.TestCase):
self.assertEqual(obj.spec, alt_obj.spec)
self.assertEqual(obj.version, alt_obj.version)
+ obj.full_clean()
+
def test_invalid_input(self):
self.assertRaises(ValueError, models.VersionModel,
version='0.1.1', spec='blah')
@@ -81,6 +83,8 @@ class DjangoFieldTestCase(unittest.TestCase):
self.assertIsNone(obj.optional)
self.assertIsNone(obj.optional_spec)
+ obj.full_clean()
+
def test_serialization(self):
o1 = models.VersionModel(version='0.1.1', spec='==0.1.1,!=0.1.1-alpha')
o2 = models.VersionModel(version='0.4.3-rc3+build3',