Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions semantic_version/django_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import django
from django.db import models
from django.core.exceptions import ValidationError

if django.VERSION >= (3, 0):
# See https://docs.djangoproject.com/en/dev/releases/3.0/#features-deprecated-in-3-0
Expand Down Expand Up @@ -75,10 +76,14 @@ def to_python(self, value):
return value
if isinstance(value, base.Version):
return value
if self.coerce:
return base.Version.coerce(value, partial=self.partial)
else:
return base.Version(value, partial=self.partial)

try:
if self.coerce:
return base.Version.coerce(value, partial=self.partial)
else:
return base.Version(value, partial=self.partial)
except ValueError as e:
raise ValidationError(str(e)) from e


class SpecField(SemVerField):
Expand Down