Courses Free Courses Interview Questions Tutorials Community
Home / Tutorial / Django Tutorial - Learn Django from Scratch
Django Tutorial - Learn Django from Scratch
By Debashis Borgohain 6.4K Views 20 min read Updated on February 6, 2024
Become a Certified Professional
In this Django tutorial series, we will talk about the basic Django concepts, such as installation, creating
projects and applications, models, views, templates, and URLs, and the advanced concepts such as
testing and deployment. We will build a web application using Django and a REST API using Django
REST Framework. Let us start with the fundamentals of Django.
Process Advisors
53% of learners received 50% and above salary hike post completion of the program*
*Subject to Terms and Condition
Django Tutorial - Learn
Django from Scratch
Introduction to Django
Django Tutorial - Learn Django Most of the web applications, apart from their core features, consist of common functionalities such as
from Scratch
authentication, database connectivity, etc. Having predefined APIs or classes to solve specific web
Build User Registration Using development problems makes Web Developers’ job a lot easier.
Django Template, Django
Model, and Django Model
Fields These predefined APIs and tools that can be used to simplify common web development operations are known as
the web framework. One of the most popular Python web frameworks is Django.
Django REST Framework
Tutorial
In case you want to jump right into a particular topic, here’s a table of contents for this Django tutorial.
What is Django Web Framework?
Why Django Web Framework?
Django Installation
Prerequisite
Django Installation Process
Architecture of Django: Model, Views, and Template
Hands-on: Step-by-step Guide to Building a Web Application Using Django
Creating a Project
Creating an Application
Creating a URL and a View for the Web Application
First of all, watch this video on ‘Django for Beginners’:
Without further ado, let’s get started.
What is Django Web Framework?
Django is a web framework written in Python. A web framework is a software that supports the development of
dynamic websites, applications, and services. It provides a set of tools and functionalities that solves many
common problems associated with web development, such as security features, database access, sessions,
template processing, URL routing, internationalization, localization, and much more.
Wish to crack Django job interviews? Intellipaat’s Top Django Interview Questions are meant only
for you!
Why Django Web Framework?
First of all, it is a Python web framework, which means that you can benefit from a wide range of open-source
libraries out there. This popular web framework also offers a standalone web server for development and testing,
caching, and middleware system. Moreover, it provides the ORM (object-relational mapper) library, the template
engine, form processing, and an interface with Python’s unit testing tools.
How to Install Django
Prerequisites for Installing Django
Check if Python is installed in the system by using the following command:
1 python ‐‐version
If Python is not installed in your system, go through this tutorial on ‘How to Download and Install Python?’
Install Django
Step 1: Open the command prompt
Step 2: Run the pip command
1 pip install django
Architecture of Django Web Framework
Django web framework follows the MVT (Model View Template) architecture. This architectural pattern is designed
for easy and rapid web development.
The model or the model class is the source of information regarding the data. In other words, the model can be
considered as the logical data structure behind the entire web application. Each model is associated with a table
in the database.
The view or the view function takes up different web requests and returns respective responses. For instance, the
request can be POST or GET type, and the response can be an HTML page, a 404 error, a redirect, or an image.
Template layer determines how a user sees the response Django returns. It basically controls the user interaction.
Let us talk about how these components communicate with each other to make the development in Django easy
and rapid.
Get 100% Hike!
Master Most in Demand Skills Now !
+91 IN INDIA
Email Address Phone Number Submit
By providing your contact details, you agree to our Terms of Use & Privacy Policy
Watch this video on ‘Python Django Tutorial’:
Python Django Tutorial | Django Course | Python Django Trainin…
Watch on
Any queries related to Django? Join our Community and clear your queries now!
First, a user requests for a resource. Django considers the request as a URL and matches it with the existing URL
paths in the urls.py file. This process of matching the user-requested URL to the one in urls.py is known as URL
mapping. Once the URL matches, Django carries out the further process.
Once the URL is mapped, Django jumps to the views.py folder and calls a view. The triggered view looks for
models and templates to interact with, and then it returns the response back to the user. Here, the model deals
with the data associated with the user request. On the other hand, the template deals with the HTML and the static
files, such as CSS files, JS files, images, etc., that are required to complete the view.
Alright, now that we know how the architecture works, let us move ahead with our Django tutorial and see how to
use Django framework to build a web application.
Hands-on: Step-by-step Guide to Building a Web Application
Using Django
We are going to build a simple web application that shows a simple message. First, we will create a Django
project and inside that directory, we will create an application, where other operations will be performed. Let us go
ahead and create a project first.
Creating a Project
In order to create a new Django project, run the following django-admin startproject command in the command
prompt.
Now, go to the folder where the command prompt was being run from. There you can find a new project directory
that looks like this.
Inside the ‘website’ directory (root directory), you will see another directory with name same as the root directory.
Inside that directory the following default python files are created.
Using these files, you will be configuring the entire project. One project can contain different applications for
different features, for instance, entire home page can be an application, user profile can be a separate
application, etc. Without much delay, let us see how to create an application.
Interested in learning Django? Enroll in our Django Course now!
Career Transition
Creating an Application
Open the command prompt
Navigate to the directory where you have created the project
Run the following command to create an app inside the project directory
1 python manage.py startapp tutorial
Here, you will see what difference this command makes inside the project directory. There is a new folder called
‘tutorial’ inside the ‘website’ directory.
Now, if you go inside the ‘tutorial’ application folder, you will see the following Python files Django created for you to
configure the application.
Alright, so far in this Django tutorial, we have learned how to create an application called ‘tutorial.’ Let us now see
how to build our very first web application using Django.
Creating a URL and a View for the Web Application
Step 1: First of all, paste the URL file inside the newly created application. You can copy this file from the website
directory
Step 2: Now, inside the primary app, which is ‘website,’ make the following configurations. Open ‘urls.py’ and add
the pattern to point to the ‘tutorial’ app. Import ‘include’ and add the path to the ‘urls.py’ file inside ‘tutorial’
1 Path(‘’,include(‘tutorial.urls’))
Step 3: Go to ‘tutorial.urls.py’ and import ‘views’ as shown below. Add the app name for future reference and add
the path to point to a homepage view for the tutorial app
1 Path(‘’,views.homepage, name=“homepage”)
Step 4: But so far we don’t have any view called homepage. So, add a simple HttpResponse view called
homepage. Don’t forget to import HttpResponse from django.http as shown below:
1 def homepage(request):
2 return HttpResponse("First App")
Step 5: Now, boot up the web server and run the following command
1 python manage.py runserver
Step 6: Open your browser location and go to the following location
You will see the string that was passed as an HttpResponse being rendered over there. This means, we have
successfully created our very first Django application.
For more advanced concepts on Django Web Framework and Django REST API, refer to this
structured Python Django Training and Certification Course!
Let us see what we learned so far in this Python Django tutorial for beginners.
What did we learn so far?
In this Django tutorial, we have covered the basic concepts of Django web framework, such as Django installation,
creating Django web framework projects, creating Django applications, and the concepts of models, views, and
templates. In addition, we built our very first web application using Django web framework. In our next section of
this tutorial, we will cover the advanced concepts such as working with models, forms, databases, and more. See
you there!
Courses you may like
Next
Course Schedule
Name Date Details
23 Mar 2024
Python Course View Details
(Sat-Sun) Weekend Batch
30 Mar 2024
Python Course View Details
(Sat-Sun) Weekend Batch
06 Apr 2024
Python Course View Details
(Sat-Sun) Weekend Batch
Browse Categories
Master Program Big Data Data Science Business Intelligence Salesforce Cloud Computing Mobile Development
Digital Marketing Database Programming Testing Project Management Website Development
Find Python Training in Other Regions
Chennai Jersey City Dubai Los Angeles San Francisco Singapore Toronto
Bangalore Chicago Houston Hyderabad London Melbourne New York San Jose
Sydney Atlanta Austin Boston Charlotte Columbus Dallas Denver Fremont
Irving Mountain View Philadelphia Phoenix San Diego Seattle Sunnyvale Washington
Ashburn Kochi Kolkata Pune Noida Jaipur Delhi Gurgaon Mumbai Lucknow
Gorakhpur Ahmedabad Vizag Chandigarh Coimbatore Trivandrum
Courses Courses Tutorials Interview Questions
Data Scientist Course AWS Solutions Architect Python Tutorial Python Interview Questions
Machine Learning Course UI UX Design Course AWS Tutorial AWS Interview Questions
Python Course Salesforce Training Devops Tutorial Data Science Interview
Questions
Devops Training Selenium Training Java Tutorial
Devops Interview Questions
Ethical Hacking Certification Artificial Intelligence Course Node Js Tutorial
Salesforce Interview Questions
Business Analyst Certification Ethical Hacking Course Cyber Security Tutorial
Java Interview Questions
Cyber Security Courses Azure Administrator Certification Salesforce Tutorial
SQL Interview Questions
Business Analytics Training Cyber Security Course Azure Tutorial
React Interview Questions
Investment Banking Course Digital Marketing Course Ethical Hacking Tutorial
Node Js Interview Questions
SQL Course Electric Vehicle Course Data Science Tutorial
Digital Marketing Interview
AWS DevOps Course Azure DevOps Course Cloud Computing Courses Questions
Full Stack Developer Course Web Development Courses Python Data Science Course
Informatica Course
Top Tutorials
Machine Learning Tutorial Power BI Tutorial SQL Tutorial Artificial Intelligence Tutorial Digital Marketing Tutorial Data Analytics Tutorial UI/UX Tutorial
Top Articles
Cloud Computing Data Science Machine Learning What is AWS Digital Marketing Cyber Security Salesforce Artificial Intelligence
×
Top Interview Questions
Django Training | Selenium
What… Interview Questions Azure Interview Questions Machine Learning Interview Questions Cyber Security Interview Questions
Business Analyst Interview Questions and Answers Data Structure Interview Questions Data Analyst Interview Questions Software Engineering Interview Questions
MEDIA CONTACT US TUTORIALS COMMUNITY INTERVIEW QUESTIONS
© Copyright 2011 - 2024 Intellipaat Software Solutions Pvt. Ltd.