Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

How to Create a Basic Project using MVT in Django ?

  • Difficulty Level : Easy
  • Last Updated : 16 Aug, 2021

Prerequisite – Django Project MVT Structure

Assuming you have gone through the previous article. This article focuses on creating a basic project to render a template using MVT architecture. We will use MVT (Models, Views, Templates) to render data to a local server.

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

Create a basic Project: 

  • To initiate a project of Django on Your PC, open Terminal and Enter the following command 
django-admin startproject projectName
  • A New Folder with the name projectName will be created. To enter in the project using the terminal enter command 
cd projectName
  • Create a new file inside the project folder where, and other files are stored and save the following code in it- 


# HttpResponse is used to
# pass the information
# back to view
from django.http import HttpResponse
# Defining a function which
# will receive request and
# perform task depending
# upon function definition
def hello_geek (request) :
    # This will return Hello Geeks
    # string as HttpResponse
    return HttpResponse("Hello Geeks")

  • Open inside project folder (projectName) and add your entry- 
    • Import hello_geek function from file. 
from projectName.views import hello_geeks

  • Add an entry in url field inside url patterns- 
path('geek/', hello_geek), 

  • Now to run the server follow these steps- 
    • Open command prompt and change directory to env_site by this command- 
$ cd env_site
  • Go to Script directory inside env_site and activate virtual environment- 
$ cd Script
$ activate
  • Return to the env_site directory and goto the project directory- 
$ cd ..
$ cd geeks_site
  • Start the server- Start the server by typing following command in cmd- 
$ python runserver
  • Checking – Open the browser and type this url-

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!