How to install Django in Windows

In this tutorial, I will show you how to use PIP to install Django in Windows. After that, you’ll verify your installation, create a project, and start a Django development server.

There are several web frameworks in the Python environment. The Django framework is one that has remained popular throughout time. It’s well-known for being stable and secure, as well as for allowing developers to complete projects quickly and on time. It’s open-source and free, and it runs on both Windows and Unix computers.

Step01: Opening cmd – install Django in Windows

To begin, go to your computer’s command prompt and type cmd. You may perform this by typing cmd into the Windows search box or by pressing the Windows logo key and R(WIN+R) to launch the Run dialogue box. When the dialogue box appears, type cmd and then OK.

The cmd window should now be visible:

install Django in Windows

You can work in any directory but in my case, I am working on the E directory by creating a new folder Project. After you’ve opened cmd on your PC, you’ll verify the installation of Python in the next section.

Step02: Verification of Python installation – install Django in Windows

You must first ensure that Python is install on your machine before installing Django.

To do so, open a command prompt and run the following command to verify the installation:

python --version
install Django in Windows

Python 3.10.0 is the version at the time of writing. It’s quite ok if your version differs from mine. Python is installed on your machine as long as the Python version is logged.

You’ll upgrade pip now that you’ve validated Python is installed on your machine.

Step03: Upgrading PIP

Python includes pip by default. However, it usually comes with an older version. Upgrading pip to the newest version is always a good idea. if you have an older version of python then click the link to install PIP.

To update pip on your machine, use the following command:

python -m pip install --upgrade pip
install Django in Windows

In my case, PIP has already been up to date. Now you’ve upgraded pip, you’ll create the project directory where you’ll install Django.

Step04: Creating Project Directory

I have already created a project directory with the name “Project” E:\Project>. If you haven’t created yet then create a new folder where you want to work on the Django project or write some commands to create a directory with cmd.

Step05: Creating the Virtual Environment

You’ll create a virtual environment for your project in this stage. In Python, a virtual environment is an isolated environment where project dependencies maybe install without impacting other Python projects. This allows you to build projects that use different Django versions.

If you don’t utilize a virtual environment, all of your projects will use the same Django version as the rest of your system. This may appear to be a positive thing until the latest version of Django is release, which has to break changes that cause your projects to fail completely.

Python Virtual Environments will explain more about the virtual environment.

Type the following command and wait a few seconds to build a virtual environment:

python -m venv new-env

Within your project directory, the command will create a directory named new-env.

Next, use the ls command to list the contents of the new-env directory to ensure it was created

ls

OR go to the directory folder and check there:

four

You’ll have to activate the virtual environment now that you’ve built the virtual environment directory.

Step06: Activating the Virtual Environment

You’ll activate the virtual environment in your directory in this stage.

To activate the virtual environment, use the following command:

new-env\Scripts\activate.bat
five

at the start of the prompt, a (new-env) This indicates that the virtual environment has been activated.

The instant you’ve activated your project’s virtual environment, the moment you’ve been waiting for has arrived. It’s time to get Django up and running!

Step07: Install Django in windows

You’ll use PIP to install Django on your machine in this part.

To install Django using pip install, use the following command:

pip install django

The command will install Django to the most recent version.

six

Ignore that warning because we already upgraded the PIP. If you want to upgrade again PIP then run the Step03 command.

After the installation is complete, verify that Django is installed. Type the following command to do so:

django-admin --version
seven

You’ve successfully installed Django on your PC; congratulations! You’ll start working on a Django project.

We will create a weather app project with Django in the next tutorial. If you are interested then click the link to go to our next tutorial.

That’s all for this article if you have any confusion contact us through our website or email us at [email protected] or by using LinkedIn

If you want to learn more about the Django programming language then click the link to see our last article What is Django Framework, and why we should learn it?

Leave a Comment