版权归作者所有,任何形式转载请联系作者.作者:petanne(来自豆瓣)来源:https://www.douban.com/note/301166150/ 1.多表连接查询:感觉django太NX了. class A(models.Model): name = models.CharField(u'名称') class B(models.Model): aa = models.ForeignKey(A)B.objects.filter(aa__name__contains='se
一.创建表 1.创建模型: 创建名为book的app,在book下的models.py中创建模型: from django.db import models # Create your models here. class Book(models.Model): id = models.AutoField(primary_key=True) name = models.CharField(max_length=64) pub_data = models.DateField() price = m
1表多对多的关系查询 准备工作创建表结构 from django.db import models # Create your models here. class Publisher(models.Model): name = models.CharField(max_length=32, verbose_name="名称") def __str__(self): return self.name class Book(models.Model): title = models.Ch