Section 1: Install Django on your local machine and run a simple page
If you have already installed Django, please jump to the next section.
If you are not sure if you have Django on your computer, please open terminal and enter:
python -c "import django; print(django.get_version())"
If you already have Django installed, it should show something like this:
If you don’t have Django, please follow the rest of these steps.
Step 1: Verify that you have Python on your computer
Django requires Python to work. Django can work with different versions of Python.
Make sure that your Python version is one of
3.2, 3.3, 3.4, 3.5 versions. Depending on the version of Django, you’ll need to make sure that you have a verified working Python version. As of May 20, 2015, version 1.8.2 is the stable release of Django.
Since Django comes along with a light SQLite database, you don’t need to worry about the database at this point.
Open your terminal and type:
If you already installed Python, something line this should show up:
If your computer doesn’t have Python, you should download it from:
You should either download the 2.7 version or 3.4 version. Since I am using 3.4 in this tutorial, 3.4 is recommended.
Step 2: Install pip
After you have made sure that you have Python, it is time to install pip.
pip is a tool that enable us to easily install Django.
If you are not sure if you have pip on you computer, you can open your terminal and enter:
If you don’t have
pip on your computer, you have to get the
get-pip.py installation file. Download the following:
curl -O https://bootstrap.pypa.io/get-pip.py
Afterwards, change directory to the location get-pip.py, go to your terminal, and enter:
Step 3: Using pip to install Django
After you make sure you have
pip installed on your computer, go to the terminal and enter:
sudo pip install Django
You will need to enter the password of your computer. You can also specify a specific version of Django to install. Since the stable release at the time of writing is 1.8.2, I’ll show the command to install that version:
sudo pip install Django==1.8.2
Section 2 : Start a project
Step 1: Create a project
Open your terminal, cd to your Desktop or the place where you want to put your project and enter the following command:
django-admin.py startproject blog
You will see a directory called
blog appear on the Desktop. It contains all the framework file to help you generate your website.
In your terminal, cd to into the
blog folder and enter:
python manage.py runserver
You will probably see:
Now, open a web browser. In the address file, enter the address that is showing in your terminal.
On the terminal and yours, by default, it will say http: //127.0.0.1: 8000
localhost on every computer.