Creating a Django based Basic Web Application - Revision Notes
CBSE Class 12 Computer Science (Python)
Creating a Django based Basic Web Application
Revision Notes
- Some important points to remember are as follows:
- A web framework is a software tool that provides a way to build and run dynamic websites and web-enabled applications.
- An HTTP Get Request refers to a way of retrieving information from the given server using a given URL over web.
- An HTTP POST request is a way to send data to the server, (e.g., data filled in an online form such as student information, file upload, etc.) using HTML forms over web.
- DJANGO is a Python based free and open source web application framework.
- Virtualenv is a useful tool which creates isolated Python environments that take care of interdependencies and let us develop different applications in isolation. Each isolated environment has different set of libraries unlike a common global set of libraries.
- A Django project refers to an entire application and an app is a submodule of the project caters to one specific functionality.
- You can create a Django project by issuing django-admin start <projectname> command.
- There are two directories/folders created with the project name and one is a subfolder of the other.
- The outer project name folder is the base directory of the project and holds all other app folder and setting modules of the project.
- The inner project folder is the project web-application folder and holds all the setting modules for the project.
- Command python manage.py startapp <appname> creates an app within a Django project.
- Django project architecture is based on MTV (Model Template View) architecture. Earlier it was also known as MVC (Model View Controller) architecture.
- Model in Django project is the data management component(s).
- Template is responsible for presentation logic for a Django project.
- View is the handling logic or business logic of a Django project that links the URLs and templates through URL routing.
- Logic tier provided by Django framework is the controller.
- Steps to create a Django project are:
- determine project and its apps
- determine for each app the http request type, model, template, view and url
- create model, template, views for the apps as per step
- and map urls to the templates through URL Configurations
- run server and test your project.
- The mapping between URL path to the views of Django Project are called URL Confs (URL configurations). The views of Django project are python functions.
- Django project views are Python functions that get HTTP request type in the form of mandatory argument request (HTTP request type).
- URL Routing is a process of resolving and mapping URLs through URL Confs in urls.py to actual templates which can be displayed in the web browser as a web page.