views:

1204

answers:

3

I am playing with a simple project based on Django framework. My IDE is PyDev/Eclipse.

I cannot make code completion work for Django code, but it works fine for standard Python libraries. I tried to add Django dir (in my case C:\Program Files\Python26\Lib\site-packages\django) to PYTHONPATH both on PyDev level (Window->Preferences->PyDev->Interpreter - Python->libraries) and on a project level (Project->Properties->PyDev - PYTHONPATH) - no luck so far.

Can you please advise what I am missing here (preferably without installing PyDev extensions).

A: 

I suggest Configuring pydev to work with django and

Getting started Eclipse/Pyddev

In the latter one there is a section specifically for code completion which mentions a problem with firewall or shell timeout. And in another section he mentions problems when (as in your case) the eclipse installations has spaces in the filepath

jitter
I've seen this post, it doesn't go into much details about configuring PYTHONPATH for Django
alsan
+1  A: 

Ok I give it another try.

Eclipse in C:\test\eclipse

Python 2.6.2 in C:\test\python-2.6.2

Django 1.0.2 final in C:\test\python-2.6.2\Lib\site-packages -> only the actual django folder not the docs, example, and so on. I did this without running setup.py as descriped in the INSTALL file.

Added C:\test\python-2.6.2 and C:\test\python-2.6.2\Lib\site-packages to the PATH variable

As described here I set the Interpreter in Eclipse by Window > preferences > pydev > Interpreter > Python. This automatically included a whole bunch of things under System libs like (C:\test\python-2.6.2\;C:\test\python-2.6.2\DLLs;C:\test\python-2.6.2\lib\site-packages;....). A whole bunch of Forced Builtins are also found.

Then I made a new "Pydev Project" added a package and there a new module with a class and a module which imports the class and calls a function from it. During writing this pressed Crtl+Space several times, and builtins as well as the new stuff from my Module where shown by code completion.

jitter
also, a hint how to make code completion work for your request parameters in the views.1. Add from django.http import HttpRequest at the top of views.py2. Add assert isinstance(request, HttpRequest) as the first code line of your view. Now you can enjoy code completion for request object. You can remove assert statement later.based on this discussion:http://www.mail-archive.com/[email protected]/msg02595.html
alsan
A: 

I solved setting the PYTHONPATH too. In the pallet Projects, right-click on the project -> properties In the PYTHONPATH configuration you have to put the folder that contains your project as a external folder.

Exemple: /var/www/my_project PYTHONPATH=/var/www/

Nako