Django + Eclipse, shell issues
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 imp开发者_JS百科ort Poll, Choice
Any idea why that is? Is it an eclipse thing? Is some path wrong somewhere in my settings.py? Thanks!
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
.
精彩评论