Django Tutorial For Beginners Day 1
Django Tutorial For Beginners Day 1
Process Advisors
53% of learners received 50% and above salary hike post completion of the program*
In case you want to jump right into a particular topic, here’s a table of contents for this Django tutorial.
Prerequisite
Django Installation Process
Creating a Project
Creating an Application
Creating a URL and a View for the Web Application
1 python ‐‐version
If Python is not installed in your system, go through this tutorial on ‘How to Download and Install Python?’
Install Django
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.
+91 IN INDIA
Email Address Phone Number Submit
By providing your contact details, you agree to our Terms of Use & Privacy Policy
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.
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.
Career Transition
Creating an Application
Run the following command to create an app inside the project directory
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.
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
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!
Next
Course Schedule
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
Chennai Jersey City Dubai Los Angeles San Francisco Singapore Toronto
Bangalore Chicago Houston Hyderabad London Melbourne New York San Jose
Irving Mountain View Philadelphia Phoenix San Diego Seattle Sunnyvale Washington
Ashburn Kochi Kolkata Pune Noida Jaipur Delhi Gurgaon Mumbai Lucknow
Data Scientist Course AWS Solutions Architect Python Tutorial Python Interview Questions
Machine Learning Course UI UX Design Course AWS Tutorial AWS Interview Questions
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
Business Analyst Interview Questions and Answers Data Structure Interview Questions Data Analyst Interview Questions Software Engineering Interview Questions