What is Django?
* Django is a web development framework for python which offers standard method for fast and effective website development.
* The primary goal of this high-level web framework is to create complex database-driven websites.
* It helps you to build and maintain quality web applications.
* It enables you to make the development process smooth and time saving for rapid development.
What is Framework?
* a web framework is a code library which help you to build a flexible, scalable, and maintainable, dynamic website, web app, web services.
* File design pattern: MVC, MVT
![]() |
Django Architecture |
Difference Between MVC and MVT Architectural Design Patterns
Aspect | MVC (Model-View-Controller) | MVT (Model-View-Template) |
---|---|---|
Components | Model, View, Controller | Model, View, Template |
Role of View | Displays the data to the user (UI) | Handles the user input and interaction; processes the request |
Role of Template | N/A | The Template is responsible for rendering the HTML/CSS (View in MVC) |
Role of Controller | Handles user input, processes it, and updates the Model | The View handles both user input and response rendering, which in MVC is split between Controller and View |
Responsibility Split | The View is only concerned with rendering and displaying data | The View is responsible for the logic of handling requests and user interactions |
Data Flow | User interacts with the View, which calls the Controller | User interacts with the View, which handles the logic and returns a Template for rendering |
Framework Examples | Ruby on Rails, Angular, ASP.NET MVC | Django |
Download & Install of Django
* First create Virtual Environment using Python by Following command: python -m venv env
* Activate Virtual Environment using following Command: env\Scripts\activate
* Install Django Using following command: pip install Django
Creating Django Project?
* Whether you are on Windows or Linux, just get a terminal or cmd prompt and navigate to the place you want your project to be created: Django-admin startproject projectname
Create Django Framework in Visual Studio Code using following command:
Create New Folder= folder name(Hrsikh)
* Manage.py : This file is kind of your project local django admin for interacting with your project via command line(start the development server, sync db...).
* __init__.py : Just for python, treat this folder as package.
* Setting.py : As the name indicates, your project settings.
* Urls.py : All links of your project and the function to call. A kind of ToC of your project.
* Wsgi.py : If you need to deploy project over WSGI.
Creating Application
* We assume you are in your project folder. In our main "projectname" folder, the same folder then manage.py: python manage.py startapp appname
Application Folder File Structure
* __init__.py : Just for python, treat this folder as package.
* Admin.py : This file helps you make the app modifiable in the admin interface.
* Models.py : This is where all the application models are stored.
* Test.py : This is where your unit tests are.
* Views.py : This is where your application views are.