1
0
mirror of https://github.com/django/django.git synced 2025-02-03 06:09:47 +00:00

Allow UUIDField to be None when deserializing

This commit is contained in:
ClairePhila 2017-02-10 17:26:02 +01:00 committed by GitHub
parent ab83d4d8fe
commit edad02af06

View File

@ -2337,6 +2337,8 @@ class UUIDField(Field):
return value.hex return value.hex
def to_python(self, value): def to_python(self, value):
if value is None:
return None
if not isinstance(value, uuid.UUID): if not isinstance(value, uuid.UUID):
try: try:
return uuid.UUID(value) return uuid.UUID(value)