11 2020 档案
摘要:先上源码: 1.注释解释是根据**kwargs去查,如果对象查到就更新一个对象,否则就创建一个对象 此外这里引用到行锁概念,阻塞当前查询对象的更新直到update_or_create() 调用save()方法结束; 整个操作是在一个事务里执行证明是可回滚的 源码select_for_update方法
阅读全文
摘要:1.安装库: pip install drf-yasg==1.20.0 2.注册app: 3.配置settings.py 同目录的urls.py路由: from django.contrib import adminfrom django.urls import pathfrom django.ur
阅读全文
摘要:3、反向生成 现在数据库中创建表 CREATE TABLE `alarm_group` ( `group_name` varchar(250) NOT NULL, `group_des` blob, `members` blob, `timestamp` datetime NOT NULL, `on
阅读全文
摘要:class AppleModel(models.Model): id=models.AutoField(primary_key=True) app_name=models.CharField(max_length=50) class Meta: db_table='tbl_apple' class
阅读全文
摘要:class AppleModel(models.Model): id=models.AutoField(primary_key=True) app_name=models.CharField(max_length=50) class Meta: db_table='tbl_apple' class
阅读全文
摘要:File "D:\workspace\mall\venv\lib\site-packages\django\db\models\fields\__init__.py", line 972, in get_prep_value return int(value)ValueError: invalid
阅读全文
摘要:Django 原生实现外键 class AppleModel(models.Model): id=models.AutoField(primary_key=True) app_name=models.CharField(max_length=50) class PickleModel(models.
阅读全文
摘要:def json_recur(data): if isinstance(data,dict): for key,value in data.items(): # print("key:",key,"value:",value,' ') if isinstance(value,dict): json_
阅读全文
摘要:>>> js=JsonModels.objects.filter(id=1).values("names").first()>>> js{'names': '1111'}>>> type(js)<class 'dict'>>>> js=JsonModels.objects.filter(id=1).
阅读全文
摘要:1.配置淘宝镜像 npm config set registry https://registry.npm.taobao.org ## 注释使用淘宝镜像,不在赘述 第一步安装vue cnpm install vue 第二步: 安装 vue-cli 如果提示: npm WARN deprecated
阅读全文
摘要:1. v-text 显示文本 2.v-html显示代码片段 3.v-pre 显示{{ }} 4.v-once console修改不能生效。只编译一次 5. v-model="msg" 双向绑定 事件绑定:@click="msg"
阅读全文
摘要:<!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title>index title</title> <script src="https://cdn.jsdelivr.net/npm/vue/dist
阅读全文
摘要:在PyTest中,提供了几种从命令行运行指定的测试集方式。 方式一,文件/模块级运行,即指定运行某一.py文件,在命令行下: 命令格式: pytest 文件名.py > pytest xxxx.py 即,直接用pytest 文件名即可,运行该py文件中所有的测试用例 方式二,目录级运行,即指定运行某
阅读全文
摘要:前端镜像库: https://npm.taobao.org/mirrors/atom/1.52.0/
阅读全文
摘要:package com.test.util; import com.csvreader.CsvReader; import jdk.nashorn.internal.runtime.regexp.joni.exception.ValueException; import java.util.Rand
阅读全文
摘要:def uuid_general(): return uuid.uuid1().hex class JsonModels(models.Model): names=models.CharField(max_length=50) attrs =JSONField(null=True) uid=mode
阅读全文
摘要:AttributeError: module 'MySQLdb.constants.FIELD_TYPE' has no attribute 'JSON' while migrating in Django __init__.py # import pymysql# pymysql.version_
阅读全文
摘要:def test_json_extractor(obj:dict,expr): # the obj must be dict get_value=jsonpath.jsonpath(obj,expr) return get_value or None def test_or_return(): ""
阅读全文
摘要:from string import Templateimport jsonclass ReplaceTepmlate(Template): delimiter ="${}"def test_example1(): a={"a":[{"c":1,'b':'${env}'},{"c":"${ip}"}
阅读全文
摘要:在 Linux 操作系统下,如何添加一个新用户到一个特定的组中?如何同时将用户添加到多个组中?又如何将一个已存在的用户移动到某个组或者给他增加一个组?对于不常用 Linux 的人来讲,记忆 Linux 那繁多的命令行操作真是件不容易的事。 在 Linux 中,增加用户或改变用户的组属性可以使用 us
阅读全文
摘要:org-docs: https://django-mysql.readthedocs.io/en/latest/model_fields/json_field.html Installation Install it with pip: $ python -m pip install django-
阅读全文
摘要:# 将官方镜像拉到本地 docker pull minio/minio # 将minio 上传到自己的私有仓库 docker tag docker-reg.xxx.com/library/minio:lastest minio/minio docker push docker-reg.xxx.com
阅读全文
摘要:官方文档介绍:https://docs.djangoproject.com/en/3.1/ref/files/storage/ 源码解读: from django.core.files.storage import FileSystemStorage 如果定义模型ImageField() img=m
阅读全文
摘要:### start from here ## 前置准备依赖c++ : yum -y install libevent libevent-devel perl make gcc zlib zlib-devel pcre pcre-devel gcc-c++ openssl-devel 1.安装libf
阅读全文
摘要:1.启动docker 基于centos7 systemctl start/restart docker 2.查看docker 状态 ps -ef |grep dockerd 3.安装minio 1.拉取镜像 minio docker pull minio/minio 2.建立容器映射:-it 表示运
阅读全文
摘要:fastdfs client库windows调用报错报错坑1: ModuleNotFoundError: No module named 'mutagen._compat'解决办法:找到utils.py文件修复导入报问题如下: from mutagen._senf._compat import St
阅读全文
摘要:注意如果你同时使用request.body和request.data时 request .body 需要在request.data 前使用,不然获取会抛异常 其次request.body用户获取非表单类型数据请求体,如果只想获取表单请求参数使用request.POST 需要获取文件使用request
阅读全文
摘要:HttpRequest对象¶ 类HttpRequest¶ 属性¶ 除非另有说明,否则所有属性都应被视为只读。 HttpRequest.scheme¶ 表示请求方案的字符串(http或https 通常)。 HttpRequest.body¶ 原始HTTP请求主体为字节串。这对于以不同于常规HTML表单
阅读全文
摘要:先说下多字段多文件的上传: # 多个字段文件上传,org explain format is: ("filename", "fileobject", "content-type", "headers") { "field1" : ("filepath中的文件名称", open("filePath1"
阅读全文