We’d walk through the process of building a blog using the Django web framework. Django is a framework written in Python that enables you to build really powerful web applications using the Python programming language. To build web apps using Django, you need to be familiar with the Python programming language. If you already are and are looking to get your hands on some real world application of your knowledge, then Django is a great place to begin your journey! So, without further ado, let’s get right into it!

Things required for our blog building exercise.

A basic understanding of the Python programming language (variables, functions, classes, and Objects)

Django, a Python web framework.

Python 2x or 3x installed on your local machine

Pip, a python package manager.

Pillow, a python image library.

A browser; Mozilla, Chrome, Opera or UC browser. Heck, even internet explorer would do

A text editor; vim, emacs, VSCode, Sublime, Atom, etc

A computer and a strong desire to learn.

With that out of the way, let’s dive in and get our hands dirty. First things first, you need to install Python on your local device. You can check if you have python installed by running the following command in your terminal:

The 10 Websites to Learn Python

python --version
If you get some version number as output, you have python installed. If you get anything other than that, you need to install python or something is wrong with your installation (if you have it installed). Assuming you’ve got python installed, let’s go ahead and set up our development environment. Whenever you work on Python projects, you want to keep your development environment separate from your regular working environment. This can be done by using the “virtual environment” tool provided to us by Python. Run the following command in your terminal to install a virtual environment:

Pip install virtualenv
That should install a virtual environment for you. Now create a directory where we would put our Blog project. I’m calling mine “djangoblog”.

Mkdir djangoblog

Cd djangoblog
Inside of the project folder, we need to create our virtual environment that would house all of the packages we would require for our project. I would call my virtual environment “venv”. By convention, you would see a lot of developers name their virtual environment venv or env. You can call yours anything you like though.

Virtualenv venv
Next, we want to activate the virtual environment.

Venv\scripts\activate
You should see something similar to this in your terminal

(venv) C:\Users\Billmike\Djangoblog
This means we are safely inside of the virtual environment created for us when we ran “Virtualenv venv” and so all of our packages would be installed and available only in this environment and not globally. Next up, we want to install Django. For this project, we would be making use of Django 1.9. The latest version as at the time of writing this is 1.11.3, and on a whole lot of levels isn’t so much different from v1.9. for a beginner starting off with Django, it is a great version to use during development and learning. That being said, let’s go ahead to install it.

Pip install Django==1.9
Awesome. You are making awesome progress. Don’t worry if this feels like hard work at first. This is the process you would go through every time you start a new project in Django during development, so the more you do it, the less time you would feel flying by *grins*. Now, we start building our blog proper. In your terminal run the following command:

django-admin startproject blog
This wouldn’t seem to do anything in your terminal, but if you open the project folder, you should now see a folder named blog. This is a basic Django project setup for you. In your terminal, change the directory to this folder and run the following commands:

Cd blog

Python manage.py runserver
 

Open your favorite browser and type in localhost:8000. You should see a message congratulating you on your success! That, my dear friend, is a working website, albeit a very basic one. Congratulations on your first Django powered website!!

Blog Commenting Sites