0. Prerequisites (Debian installation)
0.1 Installing required OS packages
sudo apt-get install python-dev python-pip git
This will install Python libraries and Git.
0.2.1 Installing MySQL
sudo apt-get install libmysqlclient-dev mysql-client mysql-server
This will install MySQL server, it will ask you to set a root password [ROOT_PASSWORD] for the MySQL server, if you haven’t already set up MySQL in the past. Remember the password.
0.2.2 Creating a local MySQL database and user (optional)
Open the MySQL shell
mysql -u root -p
and execute following queries to setup the DB
CREATE DATABASE tumedical;
GRANT ALL PRIVILEGES ON tumedical.* to tumedical_user identified by 'strong_password';
2. Setup your virtual environment
2.1. Create a virtual environment
Alternative 1:
Create an virtualenv (using virtualenv):
$ virtualenv tumedical_ve
The virtual environment should be enabled afterwards. For starting/continuing working on the project using the virtualenv, activate the virtual env using
$ source tumedical_ve/bin/activate
Alternative 2:
Create an virtualenv (using virtualenvwrapper):
$ mkvirtualenv tumedical_ve
The virtual environment should be enabled afterwards. For starting/continuing working on the project using the virtualenv, activate the virtual env using
$ workon tumedical_ve
2.2 Installing required python packages
Update pip
pip install -U pip
2.2.1 Remove InsecurePlatformWarning
Run the following command to remove the Warning
sudo pip install requests[security]
If an error occures try to install these packages
sudo apt-get install libffi-dev libxml2-dev libxslt-dev python-dev python-setuptools
2.3 Setup your virtualenv postactivate hook (optional)
This step is optional but recommended.
Every time, a virtualenv is activated with virtualenvwrappers’ workon command, a postactivate script is executed. This comes in handy to autmatically setup a projects’ environment variables and automate some reoccuring tasks. For more details on virtualenvwrapper hooks, see virtualenvwrapper: Per-User Customization.
You might consider to use this example postactivate script (located at $VIRTUAL_ENV/bin/postactivate)
#!/bin/bash
# This hook is run after this virtualenv is activated.
export DJANGO_SETTINGS_MODULE="tumedical.settings.local"
cd /path/to/tumedical.git/
git fetch --all
git status
Note: You’ll need to re-active your virtual environment after each change to it’s postactivate hook to take effect. Just run workon vp again, to make sure your current venv session has executed the postactivate hook.
3. Initialize the database with Django
Activate your env and change dir to your local forks’ git repository (if not done yet).
workon tumedical_ve
cd /path/to/tumedical.git
3.1 Run migrate management command to setup non-existing tables
./manage.py migrate
3.2 Add a superuser
./manage.py createsuperuser
You will be asked for username, email and password (twice). Remember that username and password.
4. Try running the server
./manage.py runserver
Try opening http://localhost:8000/ in your browser.
Tutorial based on https://github.com/volunteer-planner/volunteer_planner