开发者

Import existing project

I created a Django project with just a text editor and the command line, now I have installed Aptana Studio but I cannot import that pr开发者_如何学Gooject. I can create a new django project, pydev is correctly installed and it works.

In Aptana, I tried Import Projects, but it doesnt recognize my project's root directory "No projects are found to import". before replacing settings, models, views, etc,.. with the contents of my project (what I dont like), I want to ask:

Is there a better way to import the project??

You can find a more complete answer Here.


It's a bit dirty but you can do the following. Create two files in your project directory called .project and .pydevproject.

.project should contain:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>YOUR_PROJECT_NAME</name>
    <comment></comment>
    <projects>
    </projects>
        <buildSpec>
        <buildCommand>
            <name>org.python.pydev.PyDevBuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.python.pydev.pythonNature</nature>
    </natures>
</projectDescription>

and .pydevproject should contain:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?>

<pydev_project>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>\PATH\TO\THE\PROJECT</path>
</pydev_pathproperty>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.6</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
<pydev_pathproperty name="org.python.pydev.PROJECT_EXTERNAL_SOURCE_PATH">
<path>\PATH\TO\EXTERNAL\SOURCES\IF\USED</path>
</pydev_pathproperty>
</pydev_project>

when you've got those two files in your project dir you can use Import>Existing Projects into Workspace


This question is answered on the PyDev FAQ page. "How do I import existing projects/sources into PyDev?"

The easiest way seems to go through the File > New > PyDev Project wizard in Eclipse and select as the directory the directory with your sources.


Vanja's answer solved my problem... :-)

How do I import existing projects/sources into PyDev?

If the project was already in Eclipse (i.e.: has the .project and .pydevproject files), use File > Import > Existing Projects into Workspace.

Now, if the project never had the .project nor .pydevproject files, there are 2 choices:

Option 1:

Just go through the File > New > PyDev Project wizard and select as the directory the directory with your sources.

Option 2:

Create the .project and .pydevproject files from the template below and use File > Import > Existing Projects into Workspace to import it. Note that this option is more a reference for people that want to automate creating multiple projects at once.

.project contents (must replace the MyProject with the project name)

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>MyProject</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.python.pydev.PyDevBuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.python.pydev.pythonNature</nature>
    </natures>
</projectDescription>

.pydevproject contents (must replace the path (/MyProject/src) with the actual folders to be in the PYTHONPATH)

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse-pydev version="1.0"?>
<pydev_project>
    <pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
    <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
    <pydev_variables_property name="org.python.pydev.PROJECT_VARIABLE_SUBSTITUTION">
    </pydev_variables_property>
    <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
        <path>/MyProject/src</path>
    </pydev_pathproperty>
</pydev_project>

How do I import existing projects/sources for a Django project into PyDev?

Follow the same steps in the FAQ above to import a PyDev project, then right click the project > PyDev > Set as Django project and add 2 String substitution variables (on right click project > properties > PyDev PYTHONPATH)

DJANGO_MANAGE_LOCATION, which is the relative path to manage.py. i.e.: src/my_project/manage.py DJANGO_SETTINGS_MODULE, which is the name of the settings module. i.e.: my_project.settings

Note that if the .pydevproject file was created, those values could already be added to it in the entry org.python.pydev.PROJECT_VARIABLE_SUBSTITUTION:

<pydev_variables_property name="org.python.pydev.PROJECT_VARIABLE_SUBSTITUTION">
    <key>DJANGO_MANAGE_LOCATION</key>
    <value>src/my_project/manage.py</value>
    <key>DJANGO_SETTINGS_MODULE</key>
    <value>my_project.settings</value>
</pydev_variables_property>


If you are using the subclipse (svn) or egit (git) plugins, you may try to create a new project and checkout your code via the git/subclipse wizard. Might be less trouble than trying to import it.

For example, if using svn:

  1. "File > New > Project..."
  2. Select "Checkout Projects from SVN "
  3. Choose or define your svn repository
  4. On the last page of the "checkout from SVN dialog", select the radio "Open with New Project Wizard" Then follow the wizard steps there to create a project as whatever type you like (django perhaps).
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜