我的出版物上有扫描页面和文字列表。关系是这样的:
var code_cont = examplecode;
$.ajax({
type: 'POST',
url: 'https://example.com',
data: {"grant_type":'authorization_code', 'code': code_cont},
dataType: 'json',
success: function(data) {
console.log(data);
},
beforeSend : function(req) {
req.setRequestHeader('Authorization', 'Basic username:password');
},
});
现在,我有一个单词的id。如何获取包含该单词的每个出版物?另外,当给出一个出版物的id时,如何获得其中所有单词的列表?
答案 0 :(得分:0)
使用此配置,Word
只能有一个Publication
,因此无论您的模型与{{1}连接的是什么,以下查询集都会为您提供一个Publication
}从下到上而不是ForeignKey
:
ManyToManyField
同样,这将为您提供与单个对象相同的出版物:
Publication.objects.filter(page_set__link__set__word__id=word_id)
如果您想获得出版物中的所有单词:
Word.objects.get(pk=word_id).link.page.publication