Reputation: 814
Developing a project in Django with my IDE setup as Eclipse with PyDev. The following import statement:
from polls.models import Poll, Choice
works when running the project from the command line via:
python manage.py runserver
However, built in error-checking with Eclipse fails to find polls.models ("unresolved import Port"). I can fix this by adding the project name before the class and then running this. That is, make the import statement:
from projectName.polls.models import Poll, Choice
The issue is that I'm collaborating on the project and can't do this.
Question is: Is there a way to have Eclipse auto-detect or assume the projectName from the import statement?
Upvotes: 4
Views: 732
Reputation: 4528
Using projectName on import statements is not a good idea.
When working with django/python start to use virtualenv. Especially when working with eclipse/pydev. You can than configure a new interpreter for every virtualenv. Just add the virtualenv to the list of interpreters under "Preferences > PyDev > Interpreter - Python" and be sure to add your djangoproject root to the PYTHONPATH on the same preferences page.
This is essentially what django does for you when running from the command line.
Upvotes: 3