ellcub
ellcub

Reputation: 601

How to open an existing remote Django project in PyCharm

I'm pretty new to Django and Python, and I'm trying to use PyCharm for the first time. (I used to use JetBrains' PHPStorm IDE).

I have an existing Django project, running on a virtual machine. How do I open it in PyCharm?

If I choose 'Open' I get a file explorer, but it only gives me the local file structure.

If I go to Create New Project -> Django, and choose Add Remote for the interpereter, I can specify my VM using ssh credentials. But I get a message saying 'Please choose a local interpreter'. If I choose a local interpreter, it says 'Note: Django will be installed on selected interpreter'. But I don't want to install Django anywhere, as I don't actually want to create a new project.

I'm working on Ubuntu (which I'm also fairly new to, coming from a windows environment).

Upvotes: 1

Views: 1703

Answers (2)

Dagm Fekadu
Dagm Fekadu

Reputation: 610

This is easy if you are backed up with the right tools.

If you are on Linux this is pretty strait forward. It doesn't matter what project it is or what text editor you are using. All you need is ssh access.

Install sshfs

sudo apt-get install sshfs

Now access the remote directory and mount it to your disk somewhere, it is preferred if you mount it to somewhere in /media folder

sshfs [user@]hostname:[directory] mountpoint

For example

sshfs [email protected]:/path_to_remote_dir /media/temoporary_dir

Now open /media/temoporary_dir with your favorite editor and enjoy coding!

Changes will be automatically saved on the remote directory. When connection is closed the local mount directory will be empty

Upvotes: 0

ellcub
ellcub

Reputation: 601

The missing piece of the puzzle was Vagrant.

It looks like you can set up Vagrant with an existing VirtualBox VM, but I started from a Vagrant base box and re-built my VM. You can then specify synced folders between your host and guest machines.

I specified the synced folder on my local machine to be in the folder with the vagrant file. I then went to PyCharm > Open and selected the folder on my local machine.

Upvotes: 1

Related Questions