code: def validate_uuid(value):
      
  
      if value and not isinstance(value, UUID):
          try:
              return UUID(str(value), version=4)
          except (AttributeError, ValueError):
              raise ValidationError('not a valid UUID')
      return value
docs: UUID 128-bit validator