abidibo.net

Just Open Source

Deploy django application, set up another machine

deploy django git pip programming virtualenv

You can also be interested in:

This entry is related to the series "Deploy django applications with nginx, uwsgi, virtualenv, south, git and fabric", the first part here.

So what happens here? Really nothing special, I've changed my working machine and so I had to set up my django projects on the new notebook. This post is only a remainder of the followed steps.

Install all the required system packages

Clearly I had to install some packages in the new machine:

  • mysql-server
  • python
  • python-dev
  • python-setuptools
  • build-essentials
  • libmysqlclient-dev
  • git

And also I've installed pip and virtualenv

Create the folder structure and the virtualenv

First of all create a directory which will contain the project, I've created it under /var/www:

$ mkdir /var/www/myproject

Create a new vitualenv:

$ cd /var/www/myproject
$ mkdir venv
$ cd venv
$ virtualenv --no-site-packages .

Clone the remote repository

I had to clone the remote bare repository through ssh:

$ cd /var/www/myproject
$ git clone ssh://USER@HOST/path/to/bare/repository.git ./myproject

Now I have all the python code, great!

Install all project's requirements

Let's activate the virtualenv and install all the requirements with pip

$ source /var/www/myproject/venv/bin/activate
(venv) $ cd /var/www/myproject/myproject
(venv) $ pip install -r requirements.txt

Ok now we have django and all the packages needed installed in the virtualenv. But... we need a database!

Create a database, update settings.py and migrate

Create a database and update the settings.py file with the new db_name, then let's go with the db migration:

(venv) $ cd /var/www/myproject/myproject
(venv) $ python manage.py syncdb --noinput --migrate

Yeah, the db structure is up to date... but wait, I've no data inside it.. this is not really a problem, since one of the features of this deployment approach is that the synchronization process does not affect the applications' data (the production web application is constantly upgraded with new contents...), so I'll charge only the data hat I want to manually, but indeed I need at least the super admin account, so let's create it:

(venv) $ python manage.py createsuperuser

Test it

It's time to test the web application in locale

(venv) $ python manage.py runserver

Ok all is working as expected

Subscribe to abidibo.net!

Special offer!

If you subscribe to this blog within the 7 of february 2016, you'll receive a discount code of 1€ that you can use to buy my first e-book "Your Smartwatch Loves Tasker", available for purchase here on abidibo.net at the price of 3.79€!


If you want to stay up to date with new contents published on this blog, then just enter your email address, and you will receive blog updates! You can set you preferences and decide to receive emails only when articles are posted regarding a precise topic.

I promise, you'll never receive spam or advertising of any kind from this subscription, just content updates.

* indicates required

abidibo.net topics

Comments are welcome!

blog comments powered by Disqus

Your Smartwatch Loves Tasker!

Your Smartwatch Loves Tasker!

Now available for purchase!

Featured