Introduction
I have been using Microsoft Excel to do my Personal Budget. Excel is extremely powerful and has fulfilled my needs. But I always wanted to build a web application which is accessible via a browser and in order to do so we need the following:
- An admin interface (website) to plug in my expenses
- A database to store all the entries
- Code to parse the database and calculate the expenses per month
- A public interface (website) to display expense charts
After browsing the web I stumbled across Django. Django (as copied from the project page) is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. It focuses on automating as much as possible and adhering to the DRY principle.
In the first part of this tutorial we will walk through the installation of Django using Virtualenv. In the following series we will build our Personal Budget application using Django.
What is virtualenv and why use it?
Virtualenv (as copied from the project page) is a tool to create isolated Python environments. By creating an isolated environment, we can install, develop and test specific versions of software or code. It creates an environment that has its own installation directories, that doesn’t share libraries with other virtualenv environments
Objective
In this tutorial we will
- Install and configure virtualenv
- Install Django 1.7.1 on Ubuntu Server 14.10 using virtualenv
- Test our installation using the built-in Django web server
Assumptions
- Fresh Install of Ubuntu Server 14.10
- SSH enabled (sudo apt-get install ssh-server)
- User has root privileges
- Basic familiarity with using the Linux command line (terminal)
Installation
Step 1 - Get root access and update repository
apt-get update
Step 2 - Install PIP and Virtualenv
STEP 3: Install mysql server - Will be prompted for mysql root password
STEP 4: Install apache2
STEP 5: Configure database. Will be prompted for password
Enter password:
mysql> create database django;
mysql> GRANT ALL ON django.* TO django@'%' IDENTIFIED BY 'django';
mysql> quit
STEP 6: Create a virtual environment and activate it
virtualenv projects
cd projects/
. bin/activate
STEP 7: Install Django and mysql lib
pip install mysql-python
STEP 8: Create a django project
cd webapps
python -c "import django; print(django.get_version())"
Your output should say 1.7.1
STEP 9: Start the built-in web server
STEP 10: Navigate to the web browser and check your installation
Conclusion
Congratulation!! You have successfully installed Django 1.7.1. In part 2 of this tutorial we will cover how to configure Django with Apache and MySQL
part 2 ?
ReplyDelete