Sunday, October 12, 2014

Ubuntu 14.04 Django 1.7 Development With VirtualEnvWrapper and Git

I am now using Ubuntu 14.04 and Python3 as a professional developer. Now I need to setup a development environment using the latest Django 1.7 and also use Git and VirtualEnvWrapper, here is how I did it:

Update Ubuntu to the latest, from the command line:
sudo apt-get update
sudo apt-get upgrade

Lets add Git for source code versioning:
sudo apt-get install git

Ubuntu 14.04 already comes with Python 3 pre-installed, so all we need is to add the pip3 command:
sudo apt-get install python3-pip

In order to work with python3 and pip3 more as if it were the default python, add the following to the .bash_aliases file and source the file to added these new aliases:

Now all we need is to add is a development sandbox:
sudo pip install virtualenv
sudo pip install virtualenvwrapper

Add the virtualenvwrapper settings to the .bashrc file and source the file to setup the environment for use:
# VirtualEvnWrapper settings:
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/

Let's create the working environment:
pip install Django==1.7

Finally we setup Git:
git config --global 'Your Name'
git config --global your.address@your.provider

One thing to notice, is that the current Django 1.7 driver for MySQL is not working: MySQLdb. Yet the python connector supports Django and works fairly well:
pip install --allow-all-external mysql-connector-python

    'default': {
        'ENGINE': 'mysql.connector.django',
        'NAME': 'YourDatabaseName',
        'USER': 'YourUserName',
        'PASSWORD': 'YourPassword'

No comments: