Skip to main content

个人工具 用于 django 开发

Project description



适配 django 的 http 返回 json 数据

from ingrunTools.JsonToolsDjango import get_user_info, get_user_info

# get_json_models(ser, data, code, msg)    
# 栗子:        
class get_user_info(APIView):            
	user = User.object.get(pk=1)            
	return get_json_models(UserSerializer, user, 1, '查询用户信息成功') 

# {'code':1, msg: '查询用户信息成功', data: {'id':1, 'username': 'ingrun'} }

# get_json_success(msg)
# 栗子:        
class get_user_info(APIView):            
	user = User.object.get(pk=1)            
	return get_json_success('查询用户信息成功') 

# {'code':1, msg: '查询用户信息成功', data: '' }



# get_random_list(max, length, min)  返回一个包含随机不重复整数的列表
# get_random_data_list(li, length) 随机返回一个列表的一部分 不重复

# 栗子:

a = get_random_list(10, 5, -10)

print(get_random_data_list(a, 3))

# [10, -1, 9, 0, -5]
# [-1, 10, 9]

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ingrunTools, version 1.0.6
Filename, size File type Python version Upload date Hashes
Filename, size ingrunTools-1.0.6.tar.gz (3.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page