A Developer

Building A Blog Website With Django Part 1: Install Django and Creating a Project

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.

Create a root folder for your Django project. You can name it whatever you like, but for this example, I will name the root folder “myblog.” The command is very simple, “mkdir YOUR_FOLDER_NAME”.

Goes into “myblog” folder with instruction “cd”, this is abbreviation from “change directory”

To avoid conflicts with other projects on your system, it’s recommended to use a virtual environment. You can create one named “venv” by entering the following command in the terminal.

Let’s activate our virtual environment. If you are using Linux, entering command below in terminal.

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

If your virtual environment is active, the name will appear on the left side of your terminal as shown in the image below.

Install Django using pip

If you encounter an error on Windows while following the installation instructions above, please try this alternative method instead.

Create a Django project named “blogproject”. You can change the project name as you wish.

After creating a project, this is how the files and folders inside your root folder, myblog, appear.

At this time, you can run the website with limited features. Execute this command in your terminal within the root folder.

By default, when running in development mode, Django displays the website output on localhost (or 127.0.0.1) at port number 8000. To view the site, open a web browser and enter either http://127.0.0.1:8000 or http://localhost:8000. This will load the webpage as shown in the image below. The 127.0.0.1 refers to the Loopback IP and can be replaced with http://localhost. If you are running the application on a server, you’ll need to use the server’s IP address instead.

Let’s dig into our Django’s directories and files.
manage.py
: A command-line utility that allows you to interact with this Django project in various ways.
__init__.py: to make Python treat it as a package.
asgi.py: a Python file that configures and initializes an ASGI (Asynchronous Server Gateway Interface) application.
settings.py: a Python file that holds all the configurations for your Django project.
urls.py: is a Python module that acts as a URL (Uniform Resource Locator) configuration for a Django project or Django applications. It maps URLs to specific views, which are Python functions or classes that handle requests and return responses.
wsgi.py: is a Python file that acts as the entry point for web applications using the Web Server Gateway Interface (WSGI). It defines an application object that a WSGI-compatible web server can call to handle incoming HTTP requests.


admin.py: settings for the Django admin page.
apps.py: settings for the application configuration.
models.py: classes that will be converted into database tables by the Django ORM.
tests.py: test classes.
views.py: functions and classes that determine how data is displayed in the template.

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


Leave a comment

Your email address will not be published. Required fields are marked *