Reputation: 8286
I'm using pydev to use Django in Eclipse. I'm following the tutorial here (http://docs.djangoproject.com/en/dev/intro/tutorial01/), making a simple poll application. In the example when they run the shell they are able to do this:
from polls.models import Poll, Choice
however, for some reason, I'm not able to do this. In order for it to work, I have to do this:
from projectname.polls.models import Poll, Choice
Any idea why that is? Is it an eclipse thing? Is some path wrong somewhere in my settings.py? Thanks!
Upvotes: 1
Views: 1236
Reputation: 6078
I'm assuming that you're using PyDev. See how your PYTHONPATH is structured...
(right click on your project in package explorer > properties > Pydev - PYTHONPATH.
If your project is set up as
project_root/
+-projectname/
+-polls/
+-models.py
and if your PYTHONPATH points to project_root
, then you'll have to refer to Poll class as projectname.polls.models.Poll
. However, if you set the PYTHONPATH to projectname
, you can refer it to it as polls.models.Poll
.
Upvotes: 5