I have two machines for Django example development, one is a macOS the other is a Linux Ubuntu. I create a Django project in the macOS machine but now I need to develop this Django project in Linux Ubuntu, so I need to import the project in Ubuntu to edit and run, this article will tell you how to do it in Ubuntu correctly.
1. Import Existing Django Project.
The source code is maintained on GitHub, and I use a tool that name is SmartGit to control the source code versions. Please refer article How To Use SmartGit In Ubuntu to learn more. Then you can use SmartGit to clone the Django project source code to your local machine. Next, you can import the project in PyCharm follow the below steps.
- Start PyCharm and click File —> Open menu item to open the Django project selection window.
- Select the Django project saved folder, then click the OK button.
- Now the existing Django project has been opened in PyCharm correctly.
2. Enable Django Support For Existing PyCharm Project.
After you edit the source code then you need to run the Django project with the following steps.
- Select the existing Django project in PyCharm left panel.
- Click Run —> Run menu item in the top toolbar.
- Then click Edit Configurations… menu item in the popup menu list.
- The Run configuration window will pop up and there is an error message in the bottom left like below picture, the error message is Error: Please enable Django support for the project.
- Just click the Fix button at the bottom right then it will pop up another Settings window like below.
- Check the Enable Django Support checkbox, then select the Django project root folder in the Django project root: section, select the project settings.py file in the Settings: section, and select the project manage.py file in the Manage script: section.
- Then click Apply and OK button, then you can run your Django project with the specified configurations. Now you have successfully imported the existing Django project to the PyCharm installed on Ubuntu OS.