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

推荐订阅源

T
Tailwind CSS Blog
月光博客
月光博客
Recent Announcements
Recent Announcements
S
Secure Thoughts
Security Archives - TechRepublic
Security Archives - TechRepublic
T
Troy Hunt's Blog
量子位
Cloudbric
Cloudbric
L
LINUX DO - 最新话题
S
Security @ Cisco Blogs
云风的 BLOG
云风的 BLOG
MongoDB | Blog
MongoDB | Blog
博客园 - Franky
WordPress大学
WordPress大学
T
Threat Research - Cisco Blogs
Y
Y Combinator Blog
Engineering at Meta
Engineering at Meta
P
Privacy & Cybersecurity Law Blog
aimingoo的专栏
aimingoo的专栏
PCI Perspectives
PCI Perspectives
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
V2EX - 技术
V2EX - 技术
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
D
Darknet – Hacking Tools, Hacker News & Cyber Security
U
Unit 42
Schneier on Security
Schneier on Security
大猫的无限游戏
大猫的无限游戏
I
Intezer
Hacker News: Ask HN
Hacker News: Ask HN
H
Heimdal Security Blog
Cisco Talos Blog
Cisco Talos Blog
Recorded Future
Recorded Future
C
CXSECURITY Database RSS Feed - CXSecurity.com
H
Help Net Security
Latest news
Latest news
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
LangChain Blog
GbyAI
GbyAI
Google DeepMind News
Google DeepMind News
小众软件
小众软件
M
MIT News - Artificial intelligence
A
About on SuperTechFans
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
博客园 - 三生石上(FineUI控件)
D
DataBreaches.Net
NISL@THU
NISL@THU
博客园_首页
Recent Commits to openclaw:main
Recent Commits to openclaw:main
L
Lohrmann on Cybersecurity
T
Tenable Blog

博客园 - 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()