+

Django Introduction and Installation

Why Django?

  1. It`s very easy to switch the database in Django framework.
  2. It has a built-in admin interface that makes it easy to work with him.
  3. Django — it`s a fully functional framework that doesn`t require anything else.
  4. There are thousands of additional packages.
  5. It`s very scalable.

Django`s popularity
Django is used in many popular sites such as: Disqus, Instagram, Knight Foundation, MacArthur Foundation, Mozilla, National Geographic, etc. There are over 5,000 online sites based on the Django framework. (Source)
Sites like Hot Frameworks measure the popularity of a framework by counting the number of GitHub projects and StackOverflow questions for each platform, with Django in 6th position here. Web frameworks often refer to themselves as "opinionated" or "unconvinced" based on opinions about the right way to solve any particular problem. Django is somewhat cocky, hence, delivers in both worlds (cocky and unconvinced). 
Some features of Django
Versatility of Django
Django can create almost any type of site. It can also work with any client environment and can deliver content in any format like HTML, JSON, XML, etc. Some sites that can be created with Django — these are wikis, social networks, new sites, etc.

Security
Since the Django framework is built to make web development easier, it was designed this way , which automatically takes the correct steps to protect the website. For example, in the Django framework, instead of putting the password in cookies, the hashed password is stored in it so that hackers cannot easily get it.

Scalability
Websites Django has no saved state, they scale horizontally — just run more of them when you need them. The ability to do this — the essence of good scalability. Instagram and Disqus — these are two Django-based products that have millions of active users, which is an example of Django`s scalability.

portability
All the code for the Django framework is written in Python, which runs on many platforms. This causes Django to run on many platforms such as Linux, Windows and Mac OS.

Installing Django

  • Install python3 if not installed on your system (according to your system and OS configuration) from here . Try downloading the latest python — python3.6.4.
  • Note: Installing Django on Linux and Mac is similar, here I show it on Windows for Linux and Mac, just open a terminal instead of command line and run the following commands.

  • Install command line pip- Open and enter the following command
 python -m pip install -U pip 

  • Install virtual environment — enter following command in cmd-
  •  pip install virtualenv 

  • Set up a virtual environment. Setting up a virtual environment will allow you to edit dependencies that are usually not allowed by your system. 
    Follow these steps to set up the virtual environment:
    1. Create a virtual environment by running this command in cmd-
       virtualenv env_site 
    2. Change directory to env_site with this command:
       cd env_site 
    3. Go to the Script directory inside env_site and activate the virtual environment
       cd Script  
       activate 
  • Install Django. Install Django by typing the following command:
     pip install django 
  • sublist652891.jpg "/>

  • Go back to the env_site directory-
     cd .. 
  • Start a project at by running the following command:
     django-admin startproject geeks_site 
  • Change directory to geeks_site
     cd geeks_site 
  • Start the server. Start the server by entering the following command in cmd-
     python manage.py runserver 
  • To check if the server is running or not, go to your web browser and enter http://127.0.0.1:8000/ as the URL .
  • Link
    developer.mozilla.org

    Get Solution for free from DataCamp guru