因此,我目前正在学习django中的查询集和模型。我被引导到这个article,从哪个州
Lookups that span relationships
Django offers a powerful and intuitive way to “follow” relationships in lookups, taking care of the SQL JOINs for you automatically, behind the scenes. To span a relationship, just use the field name of related fields across models, separated by double underscores, until you get to the field you want.
This example retrieves all Entry objects with a Blog whose name is 'Beatles Blog':
Entry.objects.filter(blog__name='Beatles Blog') This spanning can be as deep as you’d like.
它也可以反向工作。指的是“反向”关系,只是 使用模型的小写名称。你知道吗
现在在我的例子中,我的模型已经用小写字母创建了。我应该回去把模特名字里的第一个字大写吗?你知道吗
将类名大写是PEP8的建议,而不是要求。你知道吗
对于Django模型,它不应该影响您的表名,而且应该是安全的;但是,它不会有任何功能效果,它只是一种样式改进
相关问题 更多 >
编程相关推荐