Installation Of Django: Python Framework

MVC type framework (Called MVT in Django)

  • M= Model
  • V= View
  • T= Template
Main Features of Django:
  1. A WSGI (web server gateway interface) is a standard interface between web servers and Python web applications or frameworks.
  2. Routing - www.example.com/index where /index should be routed to a particular python code that handles it.
  3. Admin Panel - Django provides an admin panel of your database tables that want to use in the admin panel.
  4. Database - It provides connectivity to many databases for change only database connectivity code.
Installation steps of Django:
  1. Download the MSI installer. Select 32 bit or 64 bit based on the System Install Python in your system.
     
  2. Run the installer. Be sure to check the option to add Python to your PATH while installing.
     
  3. Now Run Command Prompt and Enter “python”. You will see the output as below
     
    Command Prompt
     
     
  4. We need some libraries for further process like pip,virtualenv
     
  5. Now download get-pip.py file.
     
  6. Where you download the above file then open a command prompt with this directory.
     
  7. Enter Command in CMD: “python get-pip.py”. It will install pip command for use in CMD. I have already installed therefore it is shown as Requirement already up-to-date. Check it is successfully installed or not using CMD to enter the “pip” command.
     
    cmd
     
    cmd
     
  8. Now Install virtualenv library using pip. Enter Command in CMD:” pip install virtualenv”.
     
  9. After installation, open command prompt in base C: drive directory and Enter Command in CMD: “virtualenv env”.
     
  10. It will create a folder in C: base directory and copy the required files in this directory.
     
    directory
     
  11. Now again run command in CMD of base directory: “/env/Scripts/activate”.
     
    cmd
     
  12. You are in working in the virtual environment of python and also see (env) before the command directory. If you want to go out from a virtual environment then run the command “deactivate”.
     
  13. Now you can install Django in your System. Write Command in CMD with the virtual environment “pip install django”.I have already installed it.
     
    cmd
     
  14. Now go to the directory where you want to create a project of Django in command prompt. I’m creating a project in C:\Users\NeErAj\project directory.
     
  15. Write command in CMD: “django-admin startproject demo”.It creates a project demo folder with some python files.
     
    cmd
     
  16. Here manage.py are used to run the command through this file.
     
  17. In the demo folder, a new same demo already exists that contains __init__.py, settings.py, urls.py, wsgi.py files.
     
  18. Now go to inner demo “(env) C:\Users\NeErAj\project\demo> “folder in command prompt and write command: “django-admin startapp main”.
     
  19. It creates the main folder in the root demo folder that contains multiple files which are the most useful files for further use in the Django project.
     
  20. In command “django-admin startapp main”. Here “main” is an app name then you must write this app name in settings.py files in INSTALLED_APP block. Without it, you can’t use the main directory as Project.

    directory
     
  21. Now Run command in the root demo directory. “python manage.py runserver”
     
    command
     
  22. Open the browser and enter URL http://127.0.0.1:8000/.
     
    browser
     
  23. Now Django is successfully installed.
Use Django directly in Visual Studio
  1. Download python tools for visual studio at https://github.com/Microsoft/PTVS and install it.
     
  2. Now you will see in Visual Studio.
     
    vs
     
  3. You can make the Django web project directly.
     
  4. But according to me you should have knowledge about all basic commands of django for customization.


Similar Articles