Alisha Karki - Author
2025-04-09
You have chosen to explore the Python Django framework. Your drive to either meet an upcoming deadline or build your development skills exists as the motivation for learning Python Django. You have made the correct decision to be here.
The web development framework Python Django stands as one of the top choices because it enables swift application development with its outstanding power and scalability features. Learning a new framework becomes overwhelming when you need to complete it within a short time period. Don’t worry, though.
This blog provides a three-day accelerated guide to help you establish Python Django functionality. The training will provide you with the necessary skills to construct your own web applications. Ready? Let’s go!
The following discussion will explain why Django represents a valuable investment of your time. The Python-based web framework Django adopts a development approach that includes all necessary components by default.
Django provides a complete package of features including an ORM (Object-Relational Mapper) and authentication and admin panels which saves developers from starting from scratch. Django powers web applications at Instagram and Pinterest and Mozilla which proves its credibility. Web development students should consider Django as their learning platform. Novice developers can learn from Django but professionals with complex requirements will find it sufficient.
The Python foundation of Django lets you take advantage of its easy-to-use python format, simple design, and readable code structure. Win-win!
The first step requires installing Python on your computer system. Python.org provides the latest version, which you can download directly. After installing Python, you should proceed to install Pipenv, which serves as a dependency and virtual environment manager. Trust me, it’s a lifesaver.
pip3 install pipenv
After installing Pipenv, create a virtual environment for your Django project. This method keeps your project dependencies separate from the main Python installation.
mkdir myproject
cd myproject
pipenv --three
pipenv install django
The command creates a Pipfile in your project directory while installing the newest Django version.
With Django installed, it’s time to create your first project. Activate your virtual environment and run the following command:
pipenv shell
django-admin startproject myproject .
This will generate the basic structure of a framework project. The project directory contains manage.py alongside a folder with the project name. Your project setup now has a brand new first creation.
A Django project consists of various apps which function as its core components. Apps function as independent components which manage particular functions. Let’s create your first app:
python manage.py startapp myapp
Add your app to the INSTALLED_APPS list within settings.py file.
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'myapp', # Add your app here
]
Models are the backbone of any Django application. They define the structure of your database. Let’s create a simple model in models.py:
from django.db import models
class Task(models.Model):
title = models.CharField(max_length=200)
description = models.TextField()
completed = models.BooleanField(default=False)
def __str__(self):
return self.title
Once your model is ready, you’ll need to create and apply migrations:
python manage.py makemigrations
python manage.py migrate
The built-in admin panel of Django provides an easy way to handle your data management tasks. You can add your model to the admin panel by registering it in admin.py:
from django.contrib import admin
from .models import Task
admin.site.register(Task)
Now, create a superuser to access the admin panel:
python manage.py createsuperuser
Run the development server and navigate to http://127.0.0.1:8000/admin to see your model in action:
python manage.py runserver
Views handle the logic of your application, while templates define how your data is presented. Let’s create a simple view in views.py:
from django.shortcuts import render
from django.views import View
from .models import Task
class TaskListView(View):
def get(self, request):
tasks = Task.objects.all()
return render(request, 'tasks/list.html', {'tasks': tasks})
Next, create a template in templates/tasks/list.html:
<h1>My Tasks</h1>
<ul>
{% for task in tasks %}
<li>{{ task.title }}</li>
{% endfor %}
</ul>
Finally, map the view to a URL in urls.py:
from django.urls import path
from .views import TaskListView
urlpatterns = [
path('tasks/', TaskListView.as_view(), name='task_list'),
]
Python Django makes it easy to handle forms. Let’s create a form to add new tasks. First, create a forms.py file in your app:
from django import forms
from .models import Task
class TaskForm(forms.ModelForm):
class Meta:
model = Task
fields = ['title', 'description', 'completed']
Next, update your view to handle form submissions:
from django.shortcuts import redirect
from .forms import TaskForm
class TaskCreateView(View):
def get(self, request):
form = TaskForm()
return render(request, 'tasks/create.html', {'form': form})
def post(self, request):
form = TaskForm(request.POST)
if form.is_valid():
form.save()
return redirect('task_list')
return render(request, 'tasks/create.html', {'form': form})
Don’t forget to update your template to include the form:
<h1>Create a New Task</h1>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Save</button>
</form>
Every web application requires CSS to achieve an attractive design. Through its architecture Django enables the delivery of static files including CSS and JavaScript and images. Your application needs a static directory which you should establish first:
mkdir -p myapp/static/css
Add a CSS file, say styles.css, and link it in your template:
{% load static %}
<link rel="stylesheet" href="{% static 'css/styles.css' %}">
After your application reaches completion you should deploy it to make it accessible for others. Heroku stands out as an excellent deployment platform for Django beginners among the multiple available options. The official Django deployment guide provides the necessary steps to begin.
You now possess three days of Django introduction to start your development path. The online platform W3Schools provides additional Django learning resources for those seeking more guidance. The foundation you have built will lead you to create outstanding web applications using Django.
Rephrase this guide for your programming peers if you believe it gave useful instructions. Please share in the comment section what application you are developing using Django. Happy coding!
The leading IT institution in Nepal called Mindrisers provides comprehensive training for Python Django and other popular tech skills. You can join our courses which provide internships that develop your actual professional abilities. The training programs at Mindrisers match the skill level of both novices and experienced professionals. Our website contains admission information which you can access.
Recent Post
View AllNever miss an Opportunity !
We open IT skill classes Monthly in Design, Development, Deployment, Data etc.
Have something to Ask ?
get admission enquiry