Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试在我的资源中执行此操作...
thingy = fields.ToOneField(ThingyResource, 'whatzit__thingy')
即,遍历fk。我在一个资源上,whos 模型对“whatzit”有一个 fk,而“whatzit”模型对“thingy”有一个 fk。
该语法不起作用-有没有办法做到这一点,或者不建议这样做,还是其他?
或者,是否有一种直接的方法来查询对象的 uri 资源?
我想你只想这样做:
whatzit = fields.ToOneField(WhatzitResource, 'whatzit')
然后像这样脱水:
def dehydrate(self, bundle): bundle.data['thingy'] = whatzit.thingy return bundle