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) it is a standard interface between web servers and Python web applications or frameworks.

  2. Routing - www.example.com/index where /index should to be routed to a particular python code which handles it.

  3. Admin Panel - Djnago provides admin panel of your database tables which want to use in admin panel.

  4. Database - It provides connectivity to many database 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 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 above file then open 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 show as Requirement already up-to-date. Check it it is successfully installed or not using CMD to enter “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 folder in C: base directory and copy 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 virtual environment of python and also see (env) before command directory. If you want to go out from virtual environment then run command “deactivate”.

  13. Now you can install Django in your System. Write Command in CMD with virtual environment “pip install django”.I have already installed.

    cmd

  14. Now go to directory where you want create project of django in command prompt. I’m creating project in C:\Users\NeErAj\project directory.

  15. Write command in CMD: “django-admin startproject demo”.It create project demo folder with some python files.

    cmd

  16. Here manage.py are used to run command through this file.

  17. In demo folder a new same demo already exist 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 main folder in root demo folder that contains multiple files which are most useful files for further use in 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 main directory as Project.
    directory
  21. Now Run command in root demo directory. “python manage.py runserver”

    command

  22. Open 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 django web project directly.

  4. But according to me you should have knowledge about all basic commands of django for customization.

Next Recommended Readings