自动完成在Django +的PyDev [英] Autocompletion in Django + pydev

查看:144
本文介绍了自动完成在Django +的PyDev的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让从的PyDev模型数据自动完成我的变量,但现在我已经无法做到这一点。

I am trying to make pydev autocomplete my variables from model data, but for now I have been unable to do it.

我已经配置在PYTHONPATH

I have configured the PYTHONPATH in

Window->Preferences->PyDev->Interpreter - Python

要包括Django的文件夹,我的项目文件夹。

to include both the django folder and my project folder.

那么,如果我有这样一个模型:

Then if I have a model like this:

class Team(models.Model):
  name = models.CharField(max_length=50)
  id = models.IntegerField()

和来自同一个Django项目我导入此文件的另一个文件

and from another file of the same django project I import this file

from MyProject.MyApp.models import Team

code完成,如果我比如做工作(我用CTRL + SPACE给我自动完成optiosn)

Code completion works if I do for instance (I use CTRL+SPACE to show me the autocompletion optiosn)

team = Team.objects.[CTRL+SPACE]

不过,如果我要自动完成T的变量​​,这是行不通的。例如

But then it does not work if I want to 'autocomplete' the variables of t. For instance

team.[CTRL+SPACE]

不给我任何选项。
如何解决这个问题的任何想法?
谢谢

does not give me any options. Any idea on how to solve the problem? Thanks

<强>更新我已被挖更多有关该问题的起源和它不与路径配置或自动完成的配置有关,看来它与检测对象的类型做(系统不能够检测团队一个队对象,因此它不会显示对象属性)。

UPDATE: I have been digging more about the origin of the problem and it is not related with the path configuration or the autocompletion configurations, seems that it has to do with detecting the type of an object (the system is not capable of detecting that team is a Team object, and therefore it does not show the object properties).

推荐答案

你有没有加入你的站点包和项目文件夹到的PyDev PYTHONPATH?

Have you added your site packages and your project folder to the PyDev Pythonpath?

右键单击项目文件夹...

Right click on your project folder and...

的PyDev>设置为项目的PyDev

PyDev > Set as PyDev project

再次右键单击并...

Right click again and...

属性>的PyDev - PYTHONPATH

Properties > PyDev - PYTHONPATH

点击外部库。
点击添加源文件夹。
选择你的项目文件夹,也是您的站点包文件夹中。如果您使用的virtualenv,当然,你为什么不为;)你要选择合适的virtualenv的site-packages。你不必选择系统的站点包文件夹中。

Click on External Libraries. Click on Add source folder. Choose your project folder and also your site-packages folder. If you're using virtualenv, and of course, why wouldn't you be ;) you'll want to choose the appropriate virtualenv's site-packages. You do not have to choose the system site-packages folder.

现在让我们检查自动完成设置...
窗口> preferences>的PyDev>编辑> code完成

Now let's check the autocomplete settings... Window > Preferences > PyDev > Editor > Code Completion

我对所有的自动完成设置,但右括号,用0的自动完成功能延迟我也不会建议打开自动进口。

I have autocompletion set on all but the closing parenthesis, with an autocompletion delay of 0. I would also not recommend turning on auto imports.

希望,让你走!

这篇关于自动完成在Django +的PyDev的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆