Friday, August 07, 2009

Django on Eclipse (PyDEV)

This is a quickie.

To enable autocompletion in Eclipse (using Pydev plugin) you have to add the right path so the indexer can parse all the Django python files.
One way (that worked for me) is to:

gr00vy@kenny:~$ python
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> print django
module 'django' from '/var/lib/python-support/python2.6/django/__init__.pyc'
>>>

Im my case, that directory has symlinks to the real files. I added that path and it did not work, there should be no reason f
or it to not work but it didn't.
So we have to add the path where the symlinks points, and that is:

gr00vy@kenny:~$ ls -l /var/lib/python-support/python2.6/django/
lrwxrwxrwx 1 root root 58 2009-08-01 18:29 __init__.py -> /usr/share/python-support/python-django/django/__init__.py


And that's it the correct path is: /usr/share/python-support/python-django/django/

Now we open Eclipse, we go into Windows->Preferences->Pydev->Interpreter-Python and we add that path to PYTHONPATH.

We hit apply or OK and there you have it!.


0 comments: