Open In App

How to Create a Basic Project using MVT in Django ?

Last Updated : 18 Nov, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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.
 

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 views.py inside the project folder where settings.py, urls.py and other files are stored and save the following code in it- 

Python3




# 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_geeks (request) :
 
    # This will return Hello Geeks
    # string as HttpResponse
    return HttpResponse("Hello Geeks")


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

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

  • 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 manage.py runserver
  • Checking – Open the browser and type this url- 
http://127.0.0.1:8000/geek/


Previous Article
Next Article

Similar Reads

Django Project MVT Structure
Django is based on MVT (Model-View-Template) architecture. MVT is a software design pattern for developing a web application. MVT Structure has the following three parts - Model: The model is going to act as the interface of your data. It is responsible for maintaining data. It is the logical data structure behind the entire application and is repr
2 min read
Adding Tags Using Django-Taggit in Django Project
Django-Taggit is a Django application which is used to add tags to blogs, articles etc. It makes very easy for us to make adding the tags functionality to our django project.Setting up Django Project Installing django-taggit pip install django-taggitADD it to Main Project's settings.py file C/C++ Code INSTALLED_APPS = [ 'django.contrib.admin', 'dja
2 min read
Django project - Creating a Basic E-commerce Website for Displaying Products
Project Title - Basic Ecommerce Website using Django Django is a powerful framework based on python. Here we will see how to create a basic e-commerce website in Django. This project includes storing products in the database and show them on the website. Refer to the following articles to check how to create a project and an app in Django. How to C
3 min read
How to Create a basic API using Django Rest Framework ?
Django REST Framework is a wrapper over the default Django Framework, basically used to create APIs of various kinds. There are three stages before creating an API through the REST framework, Converting a Model's data to JSON/XML format (Serialization), Rendering this data to the view, and Creating a URL for mapping to the views.This article revolv
4 min read
How to create a new project in Django using Firebase Database?
Django is a Python-based web framework that allows you to quickly create efficient web applications. If you are new to Django then you can refer to Django Introduction and Installation. Here we are going to learn How to create a Django project using Firebase as Database . How to create a new project in Firebase ? Step 1: Firstly, We are going to Cr
3 min read
Create a new Django project in Pycharm using Pycharm Terminal
PyCharm is one of the most popular Python-IDE developed by JetBrains used for performing scripting in Python language. PyCharm provides many useful features like Code completion and inspection, Debugging process, support for various programming frameworks such as Flask and Django, Package Management, etc. PyCharm provides various tools for producti
2 min read
How to create a Django project?
Dive into the world of web development with Python by exploring the versatile Django framework. Django is a go-to for many developers due to its popularity, open-source license, and robust security features. It enables fast and efficient project development. In this tutorial, we will guide you through the process of installing Django on a Windows m
5 min read
Django project to create a Comments System
Commenting on a post is the most common feature a post have and implementing in Django is way more easy than in other frameworks. To implement this feature there are some number of steps which are to be followed but first lets start by creating a new project. How to create Comment Feature in Django?Open command prompt and run the following commands
6 min read
How to customize Django forms using Django Widget Tweaks ?
Django forms are a great feature to create usable forms with just few lines of code. But Django doesn't easily let us edit the form for good designs. Here, we will see one of the ways to customize Django forms, So they will look according to our wish on our HTML page. Basically we will check the methods to include our own custom css, classes, or id
3 min read
Integrating Django with Reactjs using Django REST Framework
In this article, we will learn the process of communicating between the Django Backend and React js frontend using the Django REST Framework. For the sake of a better understanding of the concept, we will be building a Simple Task Manager and go through the primary concepts for this type of integration between React js and Django. Reactjs in a nuts
18 min read
Practice Tags :