下面是一个模型设置和我正在尝试的查询的简短示例。这在django1.6中没有给我任何错误,但是在1.7中却给了我一个例外。“隐式”外键似乎在接口queryset上不可用。我尝试了select_-related('gwportprefix')和prefetch_-related('gwportprefix'),但没有成功。在
class Interface(models.Model):
# Several fields here that are not related.
pass
class GwPortPrefix(models.Model):
interface = models.ForeignKey('Interface', db_column='interfaceid')
for gwport in Interface.objects.filter(gwportprefix__isnull=False):
gwport_matches.add(gwport)
这将显示以下字段错误:
无法将关键字“gwportprefix”解析到字段中。选择是(一切都直接在接口上。无隐式外键)
在django1.7中,QuerySet/Manager实现中发生了许多更改。你试过了吗?在
相关问题 更多 >
编程相关推荐