mirror of https://github.com/django/django.git
Allow UUIDField to be None when deserializing
This commit is contained in:
parent
ab83d4d8fe
commit
edad02af06
|
@ -2337,6 +2337,8 @@ class UUIDField(Field):
|
|||
return value.hex
|
||||
|
||||
def to_python(self, value):
|
||||
if value is None:
|
||||
return None
|
||||
if not isinstance(value, uuid.UUID):
|
||||
try:
|
||||
return uuid.UUID(value)
|
||||
|
|
Loading…
Reference in New Issue