ManyToManyField 增加记录
class BOMView(View): def get(self,request):
obj=BOMForm()
return render(request,'bom.html',{'obj':obj}) def post(self,request):
data={
'father':'CC',
'son':'DD',
'usage':2.0
}
obj=BOMSheet.objects.create(usage=data['usage'])
father_id=ItemSheet.objects.filter(item=data['father']).first().id
son_id=ItemSheet.objects.filter(item=data['son']).first().id
obj.father.add(father_id)
obj.son.add(son_id)
obj.save()
return HttpResponse('ok')
总结: 好麻烦.
ManyToManyField 增加记录的更多相关文章
- Delphi 为TClientdataset定义结果集,并增加记录
Delphi 为TClientdataset定义结果集,并增加记录 procedure addDefsFieldsForCDS(aDataSet: TClientDataSet);begin aDa ...
- ORM一对多增加记录
多表操作(一对多)增加记录: 1)Bookl.objects.creat(name='python', price=77, publish_id=2) 2) pulish_obj = Publish. ...
- Serilog 自定义Enricher 来增加记录的信息
Serilog 自定义Enricher 来增加记录的信息 Intro Serilog 是 .net 里面非常不错的记录日志的库,结构化日志记录,而且配置起来很方便,自定义扩展也很方便 Serilog ...
- Serilog 自定义 Enricher 来增加记录的信息
原文:Serilog 自定义 Enricher 来增加记录的信息 Serilog 自定义 Enricher 来增加记录的信息 Intro Serilog 是 .net 里面非常不错的记录日志的库,结构 ...
- odoo-开发笔记 列表视图 增加记录弹出窗口效果
editable="bottom" 增加该标签的效果是,添加记录的时候,在原列表视图上一行一行添加; 去掉该标签之后,那么增加新记录的时候,会以弹出窗口的方式实现. 如果弹出的窗口 ...
- ABP增加记录EFCore 生成数据库脚本日志到新的txt文件
由于EFCore并没直接生成脚本到txt文件,故而自己画了点时间把实现记录下来,方便给大家参考. 0.安装Microsoft.Extensions.Logging.Debug,我这里是2.1.1版本. ...
- oracle增加记录谁在连接你的数据库
我们都知道在v$session 中记录着客户端的机器名称,但是没有IP , 如果记录clinet ip 呢? 有两种思路: ① 利用trigger,后面就是这种方式 ② 利用 DBMS_S ...
- Java_Web--JDBC 增加记录操作模板
如果不能成功链接数据库,我的博客JAVA中有详细的介绍,可以看一下 import java.sql.Connection; import java.sql.DriverManager; import ...
- .net entity framework 泛型 更新与增加记录
static public bool SaveOrUpdate<T>(T entity) where T: class { bool result = false; using (wech ...
随机推荐
- MySQL数据库SQL修改数据规范
start transaction; select id,rname,free_course_ph,cmp_id,free_date_limit_ph from ebk_students WHERE ...
- git stash 用法总结和注意点
常用git stash命令: (1)git stash save "save message" : 执行存储时,添加备注,方便查找,只有git stash 也要可以的,但查找时不 ...
- [LeetCode] 34. Find First and Last Position of Element in Sorted Array == [LintCode] 61. Search for a Range_Easy tag: Binary Search
Description Given a sorted array of n integers, find the starting and ending position of a given tar ...
- [Java in NetBeans] Lesson 17. File Input/Output.
这个课程的参考视频和图片来自youtube. 主要学到的知识点有: We want to handle the bad Error. (e.g bad input / bugs in program) ...
- CentOS6.5安装sqlite3
1.下载安装包:https://www.sqlite.org/download.html 2.解压 [root@mycentos ~]# tar xzvf sqlite-snapshot-201809 ...
- 安装Cuda9.0+cudnn7.3.1+tensorflow-gpu1.13.1
我的安装版本: win10 x64 VS2015 conda python 3.7 显卡 GTX 940mx Cuda 9.0 cudnn v7.3.1 Tensorflow-gpu 1.13.1 1 ...
- MongoDB--运行环境
版本 a.b.c a大版本 b中版本分奇数偶数 奇数是开发版 偶数是稳定版 c小版本 ssh工具:远程Linux机器.在windows下使用 Linux 下使用vim windows下使用 ...
- MySQL数据类型--与MySQL零距离接触2-5字符型
CHAR(5) : 存储abc时,由于长度不够,所以abc后面会补充2个空格,也就是abc CHAR 0-255字节 定长字符串 VARCHAR 0-65535 字节 变长字符串 ENUM('valu ...
- shell基础:用户自定义变量
- 4.后台管理系统中的ajax提交或保存的两次模态框确认
$(function () { $('.ajaxForm').ajaxForm({ beforeSubmit:showPleaseWait,//提交之前 ...