Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vagrant: how to edit files on the Vagrant server?

Tags:

vagrant

I'm following these instructions for setting up a Django app on Vagrant.

I have successfully completed them and started Django, but: how can I now edit the Django files within my usual text editor, TextMate?

I guess I can ssh and use vi to edit them from the command line, but I thought the point of Vagrant was to be able to use my usual editing tools.

I'm just not sure where the Django files are physically located.

Apologies if this question is off-topic, I'll happily post it elsewhere, if editors can let me know where is best.

like image 249
Richard Avatar asked Nov 12 '22 20:11

Richard


1 Answers

That web site is exactly the same place I started a few months ago.

Since I've learned more about Vagrant since then, I've created my own GitHub repo. You can download it here:

https://github.com/FlipperPA/djangovagrant

The way it is setup:

  • git clone the repo to a local directory on your machine
  • cd into that directory
  • run "vagrant up"
  • the directory you run "vagrant up" in is mapped to /vagrant on the guest virtual machine

Here is a working example of the way one might do it:

cd $home
git clone https://github.com/FlipperPA/djangovagrant.git
cd djangovagrant
vagrant up
vagrant ssh djangovm
cd /vagrant
django-admin.py startproject django_project
cd django_project
python manage.py runserver [::]:8000

You will then see the Django Project build on your local machine in the "djangovagrant" folder you created by the clone command above. You can you Textmate, Sublime, or any text editor you like to edit the files locally, and they'll be mapped to the guest VM.

I hope this helps - good luck.

like image 162
FlipperPA Avatar answered Dec 27 '22 09:12

FlipperPA