mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #29869 -- Made UUIDField.to_python() convert integers.
This commit is contained in:
committed by
Tim Graham
parent
fd49701ab9
commit
83c7096f2a
@@ -2319,8 +2319,9 @@ class UUIDField(Field):
|
||||
|
||||
def to_python(self, value):
|
||||
if value is not None and not isinstance(value, uuid.UUID):
|
||||
input_form = 'int' if isinstance(value, int) else 'hex'
|
||||
try:
|
||||
return uuid.UUID(value)
|
||||
return uuid.UUID(**{input_form: value})
|
||||
except (AttributeError, ValueError):
|
||||
raise exceptions.ValidationError(
|
||||
self.error_messages['invalid'],
|
||||
|
||||
Reference in New Issue
Block a user