开发者

Django (w PyCharm) & PYTHON PATH issue

I have purchased PyCharm and am trying to get things to work however I am encountering this issue..

Once I start a project everything works great...

Now if I want a standalone app.. let's say at /users/me/djangoApps I understand I have to add this directory to the python path.. I am trying to do so by creating a file sitecustomize.py at lib/python/2.6/site-packages/

However once I create an app and try to import it I keep getting non excistance errors (yes I have reloaded the python interpreter in pycharm)

开发者_JS百科I reckon I am adding my locations to the python path in the wrong way.. Also I might not have my project location setup correctly (currently /users/me/djangoProjects)

Thanks,

Novice django'r


In pycharm open the settings "cmd" + "," and then to "Project Structure" click on "Sources" to include any modules.


Don't add that file to your python site-packages, then your django project is gonna be included for all future projects down the road.

If you wanna debug, within PyCharm, click the Run tab up top and choose Edit configurations. Choose the project you are working with and make sure you add the directory where your manage.py and settings.pr file are to the "Working Directory". So I assume it might look something like this:

Working Directory: /users/me/djangoProjects/{Project Name}

If there is something else that you need to add to the Python Path, you can add it it by going to File-Settings-Python Interpreter and then add a new path in the bottom window (but once again this will be used by any project you run in PyCharm

But if you are not debugging in PyCharm and just wanna run the app, I find it easier to run it from the command line. I assume you are on Mac by your path, open the Terminal and go to the directory where your project is (same directory as the manage.py file) and type:

python manange.py runserver

If you want to give it a specific port add it to the end

python mange.py runserver 9000

This way you can edit your code in PyCharm and it will get reinterpreted when you save the file. If you are debugging in PyCharm, you need to stop the debugger and run it again to pull in your changes

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜