First Project in Django Framework;

Shubham Hanmant Pawar
3 min readJan 18, 2024

--

Django is a Python-based free and open-source web framework. It is a powerful high-level framework. It’s fast and very scalable.

In this article, we are going to learn how to install Python 3, virtualenv, create virtual environments, and install Django, and finally create a fresh project in Windows.

Let’s Learn How to run the project Step by Step:

  1. Creating a virtual environment:

Before we create a virtual environment, let’s check what Python versions we have; we can do that by typing Python in the Command Prompt. Doing so on my computer gives me the following:

Now let’s create a Virtual environment: We can do this by running the following command in the command prompt.

python -m venv my_venv

-m stands for module, and it should be followed by an existing module name

venv is a built-in module that helps us create virtual environments

my_venv is the name of the folder that will contain the virtual environment files and folders. I usually use the name Venv for that folder, but to avoid confusion, I decided to pick something different than the module name.

2. Activate the virtual environment

Now that we have our virtual environment created, let us activate it. Inside the folder “my_venv”,

We can use the “activate” file to activate our virtual environment by running the following in our terminal:

3. Install Django in the Virtual environment:

To install Django we simply do the following

pip install Django:

We can verify that Django has been installed successfully by typing this command

pip list

Great, everything seems to be working okay. Now let’s do the last step.

4. Create a local Django project

Now that we’ve installed Django successfully, we should be able to use a new command line called to create Django projects.

Here’s the Django-admin command that will create a Django project with the name “my_project”:

Django-admin startproject my_project

Now we want to go inside the my_project file

cd my_project

Now we can run the server by typing:

python manage.py runserver

When the server starts, Django will output a few messages before telling you that the development server is up and running at http://127.0.0.1:8000/. If you were wondering, 127.0.0.1 is the IP address for the local host or your local computer. The 8000 on the end is telling you that Django is listening at port 8000 on your local host.

Now that the server is running, visit http://127.0.0.1:8000/ with your web browser. You’ll see Django’s default welcome page, complete with a cool animated rocket.

And there we have it, we just created a Django project.

To exit and stop the server from running, we can simply Control+C in our terminal.

Let’s meet in the next article

Thankyou!

#vevcodelab

http://vevcodelab.com/

--

--

No responses yet