drf 常用技巧
 

自定义User模块

django shell

from django.contrib.auth import get_user_model
get_user_model()

# 默认:   <class 'django.contrib.auth.models.User'>
# 自定义: <class 'xxx.models.UserProfile'>

curl 命令

curl  http://127.0.0.1:8000/api/host \
-X POST \
-H "Content-Type: application/json" \
-d '{
"hostname": "hehe112",
"instance_id": "hehe112",
"public_ip": "10.1.1.12",
"connect_port":"65535",
"sn":"11111122"
}'

{"id":56,"hostname":"hehe112","instance_id":"hehe112","public_ip":"10.1.1.12","default_ip":null,"connect_port":"65535","ssh_id":null,"region_id":null,"account_id":null,"asset_type":"virtual_machine","cpu":null,"disk":null,"memory":null,"sn":"11111122","cabinet":null,"uhight":null,"railnum":null,"status":0,"gmt_create":"2020-10-29T23:22:48.570634","gmt_modified":"2020-10-29T23:22:48.570655","comment":""}


文章作者: 以谁为师
文章链接: http://opsbase.cn/p/drf
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源!
              
  目录