Building A Blog Website With Django Part 1

Django is a web framework developed in Python. It is open source and free to use. Django follows the Model-View-Template (MVT) architectural pattern, which separates the components of an application into three parts: the model, which handles the data; the view, which contains the logic; and the template, which is responsible for presentation.

Before we start, please install these requirements:

  • Latest version of Python, currently 3.x.x
  • pip (package installer for Python)
  • Virtual Environment
  • Microsoft Visual Studio Code (VSC) or your preferred IDE for code editor

In this tutorial I use:

  • Ubuntu 24.04.2 LTS operating system. Don’t worry, different codes in Windows will be explained but for most part there is no differences.
  • Python 3.12.3
  • pip 24.0
  • Microsoft Visual Studio for IDE

Creating a project

First of all, open your terminal or command prompt.

Make a folder named “myblog”. This is gonna be your root folder.

Goes into “myblog” folder

Install Virtual Environment named “venv”

Activate virtual environment. If you are using Linux, do this:

If you are using Windows, the activate script is inside folder “venv/Scripts/” and run it like this:

If virtual environment is active, on the left your terminal will look alike this

Install Django using pip

Sometimes If you are using Windows, there is an error even you try installing with instruction above, please do this.

Create a Django project named “blogproject”

After creating a project, these how the files and folders inside your root folder myblog

At this time, you can run the website with minimal feature. Run this syntax in your terminal inside root folder

By default in development mode, Django will display the website output on localhost, or 127.0.0.1, with port number 8000. Open a web browser and type http://127.0.0.1:8000, or http://localhost:8000 then a page will appear as shown in the picture. The 127.0.0.1 is the Loopback IP and can be replaced with http://localhost. If it is running on a server, then the IP address is the server IP address.

Next in part two we will create access to backend admin and make a super user. Part Two

Leave a Comment