29.9 C
Texas

How to install Django on Windows 10.

Hi, how are you? It’s a real pleasure to be with you again. In this opportunity, we are going to talk about a free and open-source web application framework written in Python. Indeed, I’m talking about Django. A web framework is a set of components that help to develop websites easier and faster. In other words, Django is a web framework designed to make applications of any complexity in a very reasonable time. In addition, its fundamental goal is to facilitate the creation of complex websites. As you can see, it is a framework of undoubted utility. Consequently, let’s see how to install Django on Windows 10.

Prerequisites

Django’s installation is managed from PIP. This is a package management system used to install and manage software packages written in Python. Consequently, it is indispensable to have Python installed in Windows 10. To know how to do it, please check here.

Preparing for installation.

In the first place, creates a folder in any location. I recommend the root directory. In this folder, the projects will be saved. Likewise, assign the name you want. In this case, I’ll use django.

Create a folder with the name django and place it in the root of the directory.
Create a folder with the name django and place it in the root of the directory.

Create a virtual environment for the project.

In order to develop the project, it is necessary to create a virtual environment. With this in mind, open a Command Prompt and use the CD command to go to the django folder.

- Advertisement -
cd..
cd..
cd django

Once inside the folder, proceed to create the environment, typing the following command:

py -m venv osradar

Please remember to replace osradar with the name you want to assign to the virtual environment.

Creating the virtual environment
Creating the virtual environment

Once the environment is created, all that remains is to activate it. With this in mind, please type the following command:

osradar\Scripts\activate
Activate the environment.
Activate the environment.

Downloading at installing Django

As we said at the beginning, in order to install Django, you need to use PIP. So, open a CMD from the project folder previously activated, and enter the following command:

 pip install Django==3.0.2

Press enter and wait for the wizard to download and install the framework.

Downloading and installing Django.
Downloading and installing Django.

After installing Django, it’s time to verify the installation. To do so, type the following command:

pip freeze
Testing Django's installation
Testing Django’s installation

If everything is working correctly, the console should display the version of the installed items.

Create a new project.

Then create your first project in Django. With this in mind, open a Command Prompt from the virtual environment and execute this command:

django-admin startproject Liberator

Please remember to replace the word Liberator with the name of your project.

Create a new project.
Create a new project.

Running the server

After the project is created, it’s time to run the server. With this in mind, open a CMD from the newly created project folder. Then execute this command:

python manage.py runserver

Press enter, if everything is correct the server will start.

Django server running
Django server running

After starting the server, please copy the IP address to your web browser.

Django's server running successfully.
Django’s server running successfully.

We’ve finally seen how to install Django on Windows 10. From now on you can use this powerful framework written in Python. That’s all for now, please share this post on your social networks. See you next time.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

3 COMMENTS

  1. Amazing Editorial!!
    I appreciate the fact that you have explained all the information in depth.
    Well researched & well-listed post, especially those who didn’t know how to install Django on Windows 10, they will get support for sure. Keep focusing on such topics.
    Thanks for sharing such a valuable post.

  2. If installing on Windows , then Python 3.8.5 already has pip package manager included with that Python installation. No need to install separately.
    1) if this is done for Windows, then they should download Python 3.8.5 because this version has pip package manager ported to Windows as part of installation.
    2) And then just run the command pip install Django==3.1
    3) Running this command, it will tell you that pip can be updated. Follow on screen instructions to run update.
    4) After this, django-admin command will work.

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article