) # 在Author表中主键为1的纪录
# 绑定多对多关系,即向关系表book_authors中添加纪录
book_obj.authors.add(hans,tom) # 将某些特定的...().values('name')
print(ret)
book_obj.authors.remove() # 将某个特定的对象从被关联对象集合中去除。...引入 Avg,Max,Min,Count,Sum(首字母大写)
from django.db.models import Avg,Max,Min,Count,Sum # 引入函数
返回值:...在数据库中的表名默认是 app_类名,可以通过db_table可以重写表名
index_together
联合索引
unique_together
联合唯一索引
ordering
指定默认按什么字段排序...unique_together = (("driver", "restaurant"),)
ordering = ('name',) # ordering设置默认按什么排序