How to install django on windows 10?

0
294
django

If you are into web development and often use web frameworks, then Django is something that you might want to try out. It is a high-level python web framework that allows rapid development and has a clean and pragmatic design. Also, unlike JavaScript, it doesn’t really come with your browser. Instead, you have to install it on your computer. So the question is, how to install Django on Windows 10?

Well, in case you are wondering the same, then I am here to help you out. In this article, I am going to share a step by step guide on how you can install Django on Windows 10 and get started.

So let’s just quickly get into the topic without wasting much of the time:

What is Django?

Django is a high-level Python framework for web development. It enables the rapid development of secure and maintainable websites.

Django was built by experienced web developers, and it takes care of the most hassles of web development. So you can focus on writing your app. Also, it is absolutely free and open source.

Plus, it is backed by a thriving and active community. Also, you are getting access to great documentation, and there are many options for free and paid-for support.

So if you ever face any issue with Django, you can be assured that you will get help. 

How to Install Django on Windows 10: Step by Step Guide

Install Python

The first step is to install Python on Windows 10. Django is a web framework based on Python. As a result, you will need to have Python installed on your computer.

Also, the good part is that installing Python is not as complicated as it might seem. All you have to do is go to this Python download link: https://www.python.org/downloads/. At the time of writing this article, Python 3.9.6 is the latest version.

Then from the website, you will need to download the latest version of the programming language. Also, make sure to download the executable installer and once it is downloaded, simply double click on it to start the installation wizard.

After that, you will need to check the boxes next to “Install launcher for all users (recommended)” then click “Install Now”.

After installation, open the command prompt and check that the Python version matches the version you installed by executing the following command:

py –version

Use PIP

To install Django on your Windows machine, you will need to use it. Talking about PIP, it is a package manager for python. Also, it already comes as a default module with your python installer. As a result, there is no need to install it separately.

PIP can be used for installing and uninstalling various python packages such as Django. So below, I have shared all the steps that you have to follow to install Django on Windows 10:

Setting up a virtual environment

Before you install Django, I would strongly recommend you create a dedicated environment for each of your Django projects. It helps you to separate multiple projects and lets you manage individual projects better.

Also, there are lots of options available that lets you manage environments and packages within the Python ecosystem. However, Python itself comes with venv, which allows you to manage environments better.

Also, in this article, I will be using venv only. So in order to create a virtual environment for your project, you have to follow these steps:

  •  First, go to the Windows 10 search bar and type down CMD and launch it.
  • Then navigate to the folder where you wish to create your project.
  • Next, run the following command in CMD: py -m venv project-name
  • This will create a folder named project-name. If you don’t get to see the folder, then you have to set up the virtual environment. For this, run the following command: project-name\Scripts\activate.bat

After that, the virtual environment will get activated, and you will see the “(project-name)” next to the command prompt to designate that. Each time you start a new command prompt, you’ll need to activate the environment again.

Install Django on Windows 10

To install Django windows 10 we will be using pip within your virtual environment. So once you are in your project folder and activate the venv by following the above steps. You will need to run the below command to start installing Django:

py -m pip install Django

Once you run the command, Python will start downloading and installing the latest Django release. Also, once the installation gets completed, you will need to verify your Django installation. To do this, simply run this below command within the command prompt:

django-admin –version

Start a New Project

Now once you have installed Django, let’s just ensure that it is working fine by creating a project folder. For this, we will be using the django-admin startproject command to create a project structure called testSite.

So after activating venv and entering it into the project folder, you have to run the following command:

django-admin startproject testSite

Next, you have to navigate into the testSite directory by running the below command:

cd testSite

Run the Server

Finally, let’s just run the development server and make sure that everything is working as it should be. So to run the project server, we will be using the manage.py runserver:

  • So fire up your command prompt.
  • Then run the following command:
  • python manage.py runserver
  • Next, launch your web browser and go to the following address: http://127.0.0.1:8000/.

Over here, you should see the Django web page. If you see it, then your Django installation has been successful. So now you can go ahead and create projects and start developing web apps or sites with Django.

Still having issues? Read on

If you cannot get virtualenv working which is one of the common issues faced by beginners. Then you should know that different software versions do not always work well.

So I would suggest you revisit the step where we have installed virtualenv or venv and follow all the steps carefully. Also, you can take Google’s help to get a better idea about it. Apart from this, you can also try opening a new command prompt and see if it is working properly.

In case you find issues while installing PIP, then I would advise you to use setuptools.

So for this, you have to save the “ez_setup.py” file to your desktop.

Then launch the command prompt on your Windows 10 system.

After that, run these following commands one by one:

cd Desktop

python ez_setup.py

easy_install pip

Once done, PIP should work without any issues. Also, you can try the following commands to confirm everything is working fine:

pip install virtualenv

pip freeze

pip install Django==1.11.2

You are now ready to start using Python Packages like Django!

So those were all the steps that you have to follow to install Django on Windows 10. Installing Django isn’t really a complicated task. But if you are doing it for the first time, it is obvious for you to face some issues.

But I hope the above guide will help you to install Django on Windows 10 without any trouble. So go ahead and follow the steps and see how they are working for you.

Also, if there is anything you would want to ask, then do feel free to comment below, and I will help you out.