diff --git a/src/concurrency/forms.py b/src/concurrency/forms.py index 1ca2fbe..e7ea7d2 100644 --- a/src/concurrency/forms.py +++ b/src/concurrency/forms.py @@ -91,7 +91,7 @@ def __repr__(self): return '' -class VersionField(forms.IntegerField): +class VersionField(forms.Field): widget = HiddenInput # Default widget to use when rendering this type of Field. hidden_widget = HiddenInput # Default widget to use when rendering this as "hidden". @@ -115,10 +115,11 @@ def prepare_value(self, value): return SignedValue(self._signer.sign(value)) def to_python(self, value): - try: - if value not in (None, '', 'None'): - return int(self._signer.unsign(str(value))) + value = super().to_python(value) + if value in self.empty_values: return 0 + try: + return int(self._signer.unsign(str(value))) except (BadSignature, ValueError): raise VersionError(value)