Create a Blog in Django - Installation and Setup - Django Blog #1
Hello Internet Programmer, In this tutorial we gonna build a Blog app in Django. This tutorial helps you to learn the Django framework.
Today we install Django and setup the project.
Virtual Environment Setup
Virtualenv is a tool used to create an isolated Python environment. This environment has its own installation directories that doesn’t share libraries with other virtualenv environments (and optionally doesn’t access the globally installed libraries either).
Installation
to install virtual environment just type following command in the terminal.
pip3 install virtualenv
Before making a virtual environment we make project directory. Inside it, we make a virtual environment. Type following command in terminal.
mkdir awwblog
Inside awwblog directory we setup virtual environment. Type following command in terminal.
cd awwblog/
First find your python installation path of particular version,
which python3.9
I use python3.9 here. By above command you get the path of the python3.9 (of any version)
I want python3.9 in my virtual environment. So let’s create virtual environment.
Using virtualenv
command we created env_awwblog virtual environment. Every python installation goes inside that. But before installing python stuff we need to activate the virtual environment.
Type following command.
source env_awwblog/bin/activate
Now your terminal look like this.
No, we are ready to install Django inside virtual environment. So let’s go…
Installing Django
pip3 install Django
Now Django is installed in our environment
Creating awwblog Project
Everything going fine right. Now we start the project using django-admin command.
django-admin startproject awwblog
The command should have created a awwblog directory. Use the command cd awwblog to go into the directory.
following we done,
Run following command inside awwblog directory.
python3 manage.py runserver
Just hit the url http://127.0.0.1:8000/ in browser.
Now you can see this,
If you see this in your browser, congratulation!! your Django installation is done successfully. Now we create an app.
Creating blog App
Now let’s create your first Django application. You will create a blog application
from scratch. From the project’s root directory, run the following command
python3 manage.py startapp blog
Open awwblog directory in your favorite code editor. I am using VS code. Below is the structure of how our project file structure looks like after setting up everything,
Now open settings.py in the awwblog directory. The first thing you need to do is to add the created app “blog” in the INSTALLED_APPS.
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog',
]
This holds the Django apps you’ll be using in the Django project.
That’s it for this article. In next tutorial we will build post modal to store blog posts.
Hope you like it. Please share this tutorial with your friends.
GitHub Link: https://github.com/SoniArpit/awwblog
Next: Designing the blog data schema – Django Blog #2
Who Can Help Me With a Django Blog?
If you find yourself struggling with setting up your Django blog, you have a couple of options to consider for assistance. You can hire a professional Django developer to handle the technical aspects for you. Alternatively, you can consult with companies like Webisoft that specialize in Django development and can provide you with expert guidance or services.