ORM对象关系映射
映射关系:
表名 <-------> 类名 字段 <-------> 属性 表记录 <------->类实例对象
class Customer(models.Model): ‘‘‘客户信息表‘‘‘ name = models.CharField(max_length=32,blank=True,null=True) qq = models.CharField(max_length=64,unique=True)
consult_course = models.ForeignKey("Course",verbose_name="咨询课程") content = models.TextField(verbose_name="咨询详情") tags = models.ManyToManyField("Tag",blank=True,null=True,verbose_name="分类标签") status_choices = ((0,‘已报名‘), (1,‘未报名‘), ) status = models.SmallIntegerField(choices=status_choices,default=1) consultant = models.ForeignKey("UserProfile",verbose_name="学员顾问") memo = models.TextField(blank=True,null=True,verbose_name="备注") date = models.DateTimeField(auto_now_add=True) def __str__(self): return self.qq class Meta: verbose_name ="客户表" verbose_name_plural ="客户表"
原文:http://www.cnblogs.com/venicid/p/7784955.html