# 出版社 class Publisher(models.Model): # 自增.主键 id id = models.AutoField(primary_key=True) # varchar(32).不为空.唯一索引 name = models.CharField(max_length=32, null=False, unique=True) # 书 class Booker(models.Model): id = models.AutoField(primary_key=True) tit…
字段的修改.添加和删除 create table tf1( id int primary key auto_increment, x int, y int ); #修改 alter table tf1 modify x char(4) default''; alter table tf1 change y m char(4) default ''; #增加 alter table 表名 add 字段名 类型[(长度) 约束]; >:alter table student add name cha…
Q表达式可以包裹查询条件,可以在多个条件之间进行操作:与或非等.Q表达式一般会放在filter()中进行使用,F表达式一般是放在update()中进行使用. 定义模型的models.py文件中,示例代码如下: from django.db import models # 定义作者模型 class Author(models.Model): name = models.CharField(max_length=100, unique=True) age = models.IntegerField(…