简体   繁体   English

如何将现有的django项目导入pycharm

[英]how to import an existing django project to pycharm

I have the following directory tree 我有以下目录树

myproject
├── data
├── libs
└── wsgi
    ├── openshift
    └── static

openshift contains the settings file and the manage.py file. openshift包含设置文件和manage.py文件。 I want to user manage.py through pycharm but it won't work, nor the runserver command nor the startapp neither anything to be precice. 我想通过pycharm来管理manage.py但是它不起作用,runserver命令和startapp都没有任何准确性。

running startapp gives me the following errors 运行startapp会给我以下错误

bash -cl "/usr/bin/python2.7 manage.py startapp quiz"
/usr/bin/python2.7: can't open file 'manage.py': [Errno 2] No such file or directory

Process finished with exit code 2

running runserver it gives me the following 运行runserver它给了我以下内容

ImportError: Could not import settings 'openshift.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named openshift.settings

Process finished with exit code 1

I have enabled django support and set wsig as django root project. 我启用了django支持并将wsig设置为django root项目。 Running manage.py from terminal works fine. 从终端运行manage.py工作正常。

what am i doing wrong? 我究竟做错了什么?

EDIT: running manage.py shell from pycharm also works EDIT2: I managed to get it working by following openshift's structure and making openshift the django project root folder, and some edits to the imports. 编辑:从pycharm运行manage.py shell也可以运行EDIT2:我设法通过跟随openshift的结构并使openshift成为django项目根文件夹并对导入进行一些编辑来实现它。 Now everything works great 现在一切都很好

打开myproject作为你的项目,然后转到PyCharm - > Preferences ... - > Django,启用Django支持,然后选择你的Django项目根目录,设置文件和管理脚本。

just open pycharm and in file menu select open option. 只需打开pycharm并在文件菜单中选择打开选项。 Then choose your directory and done..! 然后选择你的目录并完成..!

If you have problem with using command line then you should try building a new project from pycharm itself. 如果您在使用命令行时遇到问题,那么您应该尝试从pycharm本身构建一个新项目。

I usually change the run configuration's working directory option. 我通常会更改运行配置的工作目录选项。

You could type your working directory path into that field, then python will find the project's settings module 您可以在该字段中键入工作目录路径,然后python将找到项目的设置模块

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM