Python 代码完成Pydev Django模型外键字段

Python 代码完成Pydev Django模型外键字段,python,django,eclipse,autocomplete,pydev,Python,Django,Eclipse,Autocomplete,Pydev,Eclipse/pydev中的代码完成对我来说相当不错。然而,有一件事并不像我希望的那样有效。考虑下面的Django模型: class ReletionTree(models.Model): mother = models.ForeignKey('RelationTree', blank=True, null=True) father = models.ForeignKey('RelationTree', blank=True, null=True) name = mod

Eclipse/pydev中的代码完成对我来说相当不错。然而,有一件事并不像我希望的那样有效。考虑下面的Django模型:

class ReletionTree(models.Model):
    mother = models.ForeignKey('RelationTree', blank=True, null=True)
    father = models.ForeignKey('RelationTree', blank=True, null=True)
    name = models.CharField()

rt = RelationTree.objects.get(name='Mary') #assume unique on Mary
现在谈谈问题:

rt.        #--> will code complete and give me options mother/father/name
rt.mother. #--> will not code complete into mother/father/name, it will code 
           #    complete as if isinstance(rt.mother, models.ForeignKey) (I think)
有没有办法让Pydev明白我想让它编写完整的外键 就好像它们是它所指向的类型(在上面的案例中是RelationTree,而不是models.ForeignKey)

谢谢,David,我非常怀疑(我也做Django和Eclipse),因为Pydev不够聪明,无法理解Django用来将
father=models.ForeignKey()
转换为
father=RelationTree()
或其他什么的奇怪元类


Python对于自动完成程序来说真的很难解析,而PyDev和PyLint似乎完全放弃了元类。(pylint总是抱怨我的模型类没有
对象
成员!)

大约3年多后,我6个月的项目仍然没有完成(=。但是我现在知道:

  • 您应该使用eclipse+pyDev,而不是eclipse+pyDev。在我看来,它们的免费版本对于python开发来说是更好的选择
  • Pycharm专业版还支持django代码完成。它为我节省了大量时间