001 What & Why Django?
Before jumping into Django, let’s step back.
First question: What is a web framework?
In simple words, a web framework is a tool that helps you build websites or web applications faster. Instead of writing everything from scratch, like handling requests, connecting to a database, managing security, or rendering HTML – you get a ready-made toolbox that already solves these common problems.
Here’s the Analogy, Imagine you’re working with networking devices.
A web framework is like the operating system + built-in features of a router or firewall. You don’t have to code Access Control Lists (ACLs), NAT, VPN, or Routing Protocols from scratch they come ready inside the box.
On the other hand, if you just bought an unmanaged switch or a basic hub, you’d have to figure out everything manually.
So, What is Django?
Django is one specific web framework.
It’s known as a “batteries-included” framework, meaning it already comes with a lot of built-in features you’ll need for most websites:
-
Authentication (login/logout, users). Database management, Admin dashboard, Security protections, Templating system, URL routing
With Django, you get a full professional toolbox right out of the gate.
Django vs Flask: Another Analogy?

You might have heard of Flask, yes, it’s another web framework in Python. But it’s different.
Django is like buying a Cisco or Juniper router.
Flask is more like getting a Mikrotik or even a Linux box with just network interfaces.
In case you aren’t aware, Django is a powerful web framework for Python. There’s been use to build website like Instagram, Spotify and Dropbox.
002 Installation & Setup?
Download Python
Install Django
#pip3 install django
Install Visual Studio Code
#Install Remote – SSH Extension
Once you have installed everything, you need to connect to host from VS code to your Django Server IP. In my case it will be 192.168.1.49.
Lets begin by setting up Django, then connect to Django terminal using VScode.
#django-admin startproject [name of the project]
#django-admin startproject demo
It will generate a new directory for you that contains bunch of files that pre-generated by Django.
1. init.py – Special file that tell python to treat this directory like a python package.
2. Asgi & wsgi – Allow Django to communicate with web server.
3. Settings.py – Contains bunch of different settings, django application, install plug-ins, change of the middleware and database engine.
4. Urls.py – Allow us to configure different URL routes that we can then kind route or direct different Django Applications.]
5. Manages.py – Allow us to run special command. do things like make database migration, run python servers and all kinds of other things like creating users for Django admin panel.
Django App – is a standalone application that you can plug and play, meaninig I can take it out of this Django Project and put it into another Django project. These apps contains things like database models, different views or routes, templates, all kinds of other stuff we can have inside if our application.
To make an App, Follow these steps:
1. Go to the Django project #cd Demo
2. #python manage.py startapp [name of the app] in my case myapp.
This is going to create an application called “myapp” which contains a bunch of different files. (except urls.py)
Once we created the application we need to link this to our Django Project.
Linking App to Django Project
1. Go to the main folder under your project > Go to setting.py
2. Under Installed apps > Add your “myapp” app
Create a new URL.py under “myapp”
Configure the views.py under “myapp”.
Under your main “Demo” create a URL route that allow us to connect to our application.
How to use a Template?
First, Template is a reusable HTML file that allows us to display dynamic data. So let’s create a template.
Under “myapp”, create a folder name as “templates”, name it as templates or it won’t work.
Under “myapp”. create a new models.
Go to admin.py to register different models so that they will appear inside our admin panel allowing us to modify and view them.
So anytime you make a change to your database models, you need to make something know as migration. This migration is an automated code which Django will apply to the database which allow you to change your models and update them while kind of maintaining that data and ensuring that if data already exists in the database, youre gonna break or remove that when you make a change on the database schema.
Execute
#python manage.py makemigrations
#python manage.py migrate
Django Admin Panel – Allow us to manage users in different database mode. Let’s create a user.
#python manage.py createsuperuser
Run your application
#python manage.py runserver
#Access the url /admin (http://127.0.0.1:8000/admin/)
Main Dashboard:
003 Breaking down what we learned from our last Django project
- When working with Django, one of the first commands you’ll encounter is:
$ django-admin startproject {ProjectName}
-
The
startprojectsub-command initializes a new Django project. -
A Django project represents your entire website—it’s the container that holds all the settings, apps, and configurations needed to build and run your site.
- For example, running:
$ django-admin startproject {ProjectName}
will create a directory structure like this:
demo/ # Main project folder
manage.py # Command-line utility for managing the project
demo/ # Inner project folder with settings and core files
__init__.py
settings.py
urls.py
asgi.py
wsgi.py
demo/ is the main folder, it also create a demo/ sub-folder that contains important Python files that define project-wide settings, URL configurations, and entry points for deployment.
$ manage.py – to give commands related to our django project. So example, to run the server then you need to run the manage.py file or give command to database. We don’t need to change anything here. Let’s review the python files inside the sub-folder.
$ _init_.py – An empty file that tells Python that this directory should be considered a python package.
$ settings.py – Holds all the settings/configuration for our Django project.
$ urls.py – contains all urls for this Django projects.
$ asgi.py & wsgi.py – used when deploying django project.
Running server
$ python manage.py
$ cd “demo”
$ python manage.py runserver
#2 urls & views
# Views will handle the incoming request and will return this hello world response.{APP:post}from django.http import HttpResponse# Functiondef helloWorld(request):return HttpResponse(“Hello World!”)# By default we have URL patterns variable and it is a list.# We create the URL inside the URL variable urlpatterns.{APP:default}#import view: [posts = app]from posts import viewsurlpatterns = [ #Defaultpath(‘admin/’, admin.site.urls), #Defaultpath(‘post/helloworld/’,views.helloWorld)]!! Page not found error 404 and because we are not handling the root URL.! What will happen when user will type the domain of our website!# Now instead of writing our URL in the default app, we are creating it inside the new app.# Create a new URL on your new created app.# So we have to import that path fuction to create URL.from django.urls import pathfrom . import views# Manually create the urlpattern.urlpatterns = [path(‘post/helloworld/’,views.helloWorld)]!! Page not found error 404 because when we requested this URL post slash hello world ! Django tried to seach for this URL.!! When user request post/helloworld/, Django tried to search for this URL inside the ! project default URL.py.!! As we didn’t define the URL inside the project, django was not able to find it and ! it returned a error.!# import include# Solution: Create a URL inside the project file as wellurlpatterns = [ #Defaultpath(‘admin/’, admin.site.urls), #Defaultpath(‘post/’, include(‘posts.urls’)) # We are telling Django that whenever user will request post/, go to the posts app url.py]