How to install Django on Windows 10
Django is a free and open source web framework which follows the Model-Template-View(MTV).It is an extremely popular and fully featured server-side web framework, written in Python.It enables rapid development of secure and maintainable website.
Let’s dive into the installation steps,
Step 1 : Installing Python
- Download latest version of python using the link.https://www.python.org/downloads
- Make sure to enable the checkbox “Added to the path” while installing python.
- To check the installation of python,use the command on command prompt,
python -v
- If python is installed in your system, you will get the version of the python while running the python -v command.
Step 2 : Installing PiP
- Pip is mostly included in python package itself.
- To check the installation of pip, use the below command on cmd
pip -v
- If pip is installed in your system, you will get the version details of the pip while using the pip -v command.
Step 3 : Creating Virtual Environment
- Virtual Environment is required to run Django apps. It saves the memory of the system by creating a virtual environment in the system.To create the virtual environment, the below mentioned command is used.
pip install virtualenv
Step 4 : Creating virtual environment folder
- To create a virtual folder post to virtual environment creation, use the command to create folder inside the virtual environment,
py -m venv environmentfoldername
Ex:py -m venu myenvironment
- To check the creation of a virtual folder, run the command dir on command prompt.It will list the directories inside the virtual folder.
Step 5 : To activate the environment
- Before using any Django app,we need to activate the environment. To activate the environment,
virtualenvironmentname\scripts\activate
Ex:myenvironment\scripts\activate
- To check the installed list in your virtual environment, you can also use pip list command.
- If the installed pip version is not compatible with virtual environment version,then upgrade the pip version by using,
py -m pip install — upgrade pip
Step 6: Installing Django
- To install Django on your system, run the command on your command prompt.
pip install django
- To check the installed package list,
pip list
Step 7: Creating Django project
- To create Django project folder,
django-admin startproject projectname
Ex: django-admin startproject firstname
- To list the project name, dir command is used.
Step 8 :Creating Django app
- It should be created inside the Django folder which you created in the previous step.
python manage.py startapp appname
Ex: python manage.py startapp poll
Step 9: Running the Django Server
- To run the Django server, first move to the project folder using cd command.
manage.py runserver
- Server starts to run on back end. Port number for Django server is 8000
Step 10 : Working with Django project
Let’s see the below steps to understand how to work on Django project after the complete installation,
- Activate Virtual environment
- Move to the folder path
- Open the editor
- Run the server if you need to run the code.
Regards,
Rasega Prabakar