-1

Currently, there is no option in eclipse to import a Django project even after installing PyDev in eclipse. I followed a solution which asks to generate a new python project and then copy .project and .pyproject to the existing project but eclipse throws an error "source folder is not found".

Haris Muzaffar
  • 404
  • 6
  • 17
  • Possible duplicate of [How to import existing Android project into Eclipse?](https://stackoverflow.com/questions/2231474/how-to-import-existing-android-project-into-eclipse) – Joaquin Aug 13 '18 at 04:32
  • I would recommend abandoning PyDev altogether in favour of PyCharm. Works much better and you just need to open the project. No need to import it. – Ramtin Aug 13 '18 at 04:33
  • I would prefer eclipse as new software installation is not entertained in my office laptop? – Haris Muzaffar Aug 13 '18 at 04:58

2 Answers2

0

So for now what i did is to create a new django project with the same name as my existing project, copy .project and .pydevproject files to my existing root folder project.Delete this newly created project and import the existing project as a general project Then edit .pydevproject and delete the tag which mentions .src folder.

Haris Muzaffar
  • 404
  • 6
  • 17
0

So 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. 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.

Sonia Rani
  • 608
  • 9
  • 4