如何使用以下代码通过Reporter模型访问文章?
from django.db import models
class Reporter(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
email = models.EmailField()
class Article(models.Model):
headline = models.CharField(max_length=100)
pub_date = models.DateField()
reporter = models.ForeignKey(Reporter, on_delete=models.CASCADE)
例如在Sqlalchemy中,我们将在Reporter模型中使用以下方式创建Realshipship:
reporter_article = db.relationship('Article', backref='reporter_article ', lazy='dynamic')
位于Reporter模型中,然后我们可以直接调用Reporter.query.reporter_article.all()
我该如何致电以获取记者的所有文章?