How To Convert An Existing Django Project To Eclipse Project

mainSo you have a Django project and you want to use Eclipse IDE to modify and control it. When I say “existing Django project”, I mean a Django project created without using Eclipse. If you are not sure how to use Eclipse to manage your Python project, you can check out this blog post. You basically need to install PyDev and configure the Python path for Eclipse. Once you install everything, you should be able to see PyDev listed when you start a new Eclipse project.  

Coming back to the problem at hand, let’s say you have a Django project named “mysite”. This is the main folder which contains manage.py, settings.py, etc. Navigate to this folder on your terminal and create a file named .project:

$ cd /path/to/mysite
$ vi .project

Inside this file, paste the following code:

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

Now create another file named .pydevproject:

$ vi .pydevproject

Add the following content to that file:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?>
<pydev_project>
<pydev_variables_property name="org.python.pydev.PROJECT_VARIABLE_SUBSTITUTION">
<key>DJANGO_MANAGE_LOCATION</key>
<value>mysite/manage.py</value>
</pydev_variables_property>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/mysite/apps</path>
</pydev_pathproperty>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
</pydev_project>

For the PROJECT_SOURCE_PATH in this file (the path in line 10), the apps are usually placed inside the mysite/apps/ directory. Make sure you change this path if you have placed your source in a different folder.

Now open Eclipse and choose “File > Import”. Navigate to “mysite” and choose that as your location. Eclipse should recognize this as an Eclipse project and import it to your workspace. And we are done! You are good to go.

———————————————————————————————–

4 thoughts on “How To Convert An Existing Django Project To Eclipse Project

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s