惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
有赞技术团队
有赞技术团队
T
The Blog of Author Tim Ferriss
F
Fortinet All Blogs
D
DataBreaches.Net
F
Full Disclosure
腾讯CDC
博客园 - 【当耐特】
MyScale Blog
MyScale Blog
Stack Overflow Blog
Stack Overflow Blog
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
大猫的无限游戏
大猫的无限游戏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
SegmentFault 最新的问题
The Register - Security
The Register - Security
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
J
Java Code Geeks
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Privacy International News Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tor Project blog
博客园 - 三生石上(FineUI控件)
Know Your Adversary
Know Your Adversary
AWS News Blog
AWS News Blog
G
Google Developers Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
CERT Recently Published Vulnerability Notes
O
OpenAI News
Project Zero
Project Zero
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Application and Cybersecurity Blog
Application and Cybersecurity Blog
云风的 BLOG
云风的 BLOG
N
News and Events Feed by Topic
MongoDB | Blog
MongoDB | Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Microsoft Security Blog
Microsoft Security Blog
Cisco Talos Blog
Cisco Talos Blog
P
Palo Alto Networks Blog
Schneier on Security
Schneier on Security

博客园 - whitesky-root

windows python虚拟环境配置 git clone加速 Ubuntu 22.04 x86_64 cron不执行原因 k8s之认证文件失效,导致kubelet无法正常启动 supervisor 配置 安装 oop坑 jenkins打包报错: golang 效率工具库 gcc免编译安装配置 运维 chroot mysql lost connection to mysql server during query jdk镜像制作 curl 测试websocket请求 kubeadm reset 重置 VMware虚拟机无法联网 python 数据库连接池 Git找回add 后,未commit的文件(使用reset -hard 命令导致文件清除) set -e -x k8s pod重启 deployment重启
django jsonfield字段更新的坑
whitesky-root · 2023-03-24 · via 博客园 - whitesky-root

简单json字段:{"name":"test", "age":30, "email":"tet@gmail.com"},  可以通过obj.jsonfiledName["name"] ="test2",  obj.save()方式可成功写入数据库;

复杂json字段如,更新number字段,需使用特殊的更新方式:https://django-postgres-extensions.readthedocs.io/en/latest/json.html; 或者单独处理obj.jsonfiledName = after_update_jsonfiledName, obj.save()

{
  "name": "John Smith",
  "age": 30,
  "email": "john.smith@example.com",
  "address": {
    "street": "123 Main St",
    "city": "Anytown",
    "state": "CA",
    "zip": "12345"
  },
  "phoneNumbers": [
    {
      "type": "home",
      "number": "555-555-1234"
    },
    {
      "type": "work",
      "number": "555-555-5678"
    }
  ]
}
    m_attrs = obj.module_attrs
    if bus_obj:
        for env in ['test', 'pre', 'prod']:
            # m_attrs[env]["kube_cluster"] = bus_obj.default_cluster
            if env == "test":
                m_attrs[env]["kube_cluster"] = bus_obj.test_cluster
            if env == "pre":
                m_attrs[env]["namespace"] = bus_obj.name_space
                m_attrs[env]["kube_cluster"] = bus_obj.pre_cluster
                if bus_obj.business_name in zhenai_biz:
                    m_attrs[env]["profile"] = "qa"
                if bus_obj.business_name in crm_biz:
                    m_attrs[env]["profile"] = "pre"
            if env == "prod":
                m_attrs[env]["namespace"] = bus_obj.name_space
                m_attrs[env]["kube_cluster"] = bus_obj.prod_cluster
                if bus_obj.business_name in z_biz:
                    m_attrs[env]["profile"] = "online"
                if bus_obj.business_name in crm_biz:
                    m_attrs[env]["profile"] = "prod"
            # if self.module_attrs[env]["kube_cluster"] == 'offline':
            #     self.module_attrs[env]["logs"] = '/data/logs'
        obj.module_attrs = m_attrs
        obj.save()