django外鍵以及主表和子表的相互查詢
阿新 • • 發佈:2019-01-29
net create reat col ted 作用 log () color
Django的外鍵使用
from django.db import models # Create your models here. class Category(models.Model): name = models.CharField(max_length=100) class Article(models.Model): title = models.CharField(max_length=100) content = models.TextField() # 是由Category影響Article category = models.ForeignKey(‘Category‘,on_delete=models.CASCADE,related_name="article_category")
https://blog.csdn.net/xujin0/article/details/83552349
通過主表查詢子表、通過子表查詢主表、字段related_name的作用:
https://blog.csdn.net/hpu_yly_bj/article/details/78939748
django外鍵以及主表和子表的相互查詢