From 35af1ec18b7c84c4c5bf6b2b9f7a72049e081132 Mon Sep 17 00:00:00 2001 From: IUTA Date: Wed, 16 Nov 2022 13:20:58 +0300 Subject: [PATCH] What is Django and its installation --- backend/django.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 backend/django.md diff --git a/backend/django.md b/backend/django.md new file mode 100644 index 0000000..1f49747 --- /dev/null +++ b/backend/django.md @@ -0,0 +1,51 @@ +# What is Django + +  The Django framework implements the Model-View-Template architectural pattern,\ +  or MVT for short, which is actually a modification of the MVC (Model-View-Controller) pattern common in web programming. + +The main elements of the pattern: + +-   URL dispatcher: When a request is received, based on the requested URL,\ +   determines which resource should handle this request. +-   View: receives a request, processes it, and sends some response back to the user.\ +   If processing a request requires access to the model and database, then the View interacts with them.\ +   Can use Template or templates to create a response.\ +   In the MVC architecture, controllers (but not views) correspond to this component.\ +-   Model: describes the data used in the application.\ +   Individual classes generally correspond to tables in a database.\ +-   Template: Represents the presentation logic as generated html markup.\ +   In MVC, this component corresponds to View, that is, views. + + +# Installing and configuring Django + +## Pip package manager + +  If pip was previously installed, you can update it with the command +-   `pip install --upgrade pip` + +## Installing a virtual environment (venv) + +  Create a virtual environment +-   `python -m venv .venv` + +## Activating a virtual environment + +  Activation in Windows on the command line +-   `.venv\Scripts\activate.bat` + +  Activation on Linux and MacOS +-   `source .venv/bin/activate` + +## Installing Django + +  Installing Django +-   `python -m pip install Django` + +  If we are interested in a specific version of Django, then we can specify it during installation: +-   `python -m pip install django~=4.0.0` + +## Deactivate a virtual environment + +  After finishing working with the virtual environment, we can deactivate it using the command: +-   `deactivate`