A Quick Guide to Setting Up Your Very First Django Project
Tags: python, django, webdev
Published: 2023-04-04 16:13:47

![Code Coding GIF by EscuelaDevRock](https://media0.giphy.com/media/KAq5w47R9rmTuvWOWa/giphy.gif?cid=ecf05e47n49wdid3fneysjwv4k8qwrm5a2amscefv463pkiz&rid=giphy.gif&ct=g align="center")

Have you been eager to start building web applications with Python but don't know where to begin? Look no further than Django! As a beginner-friendly web framework, Django offers a powerful and flexible platform for developing web applications quickly and efficiently. In this blog, I'll guide you through the process of starting your first Django project and help you take your first steps toward building your web application.

![Vintage Technology GIF by Beeld & Geluid](https://media2.giphy.com/media/RFoFcwdUDQOGJAuJ9Q/giphy.gif?cid=ecf05e47dmmh1remkolvfk0dptuk8myhodlz3v3sh4dg99jb&rid=giphy.gif&ct=g align="center")

As a new developer myself, I found setting up a Django project to be a daunting task. With the numerous options and configurations available, it's easy to get lost and frustrated. However, after several attempts, I was finally able to create my first Django project and realized that the process was not as difficult as I had initially thought. That's why I'm writing this article - to help fellow beginners overcome the confusion and simplify the process of starting their first Django project. With this guide, I hope to make the process much more manageable and approachable for anyone who is just starting with Django.

---

# Installing Django

* Create a Virtual Environment
    
* Activating The Virtual Environment
    
* PIP Install Django
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679079899567/f6a9f7ad-bfb4-4e0c-a72e-343a8b863685.png align="center")

### Creating a Virtual Environment

Before we install Django, we want to create a virtual environment. A virtual environment allows us to have an environment where we can install all of our dependencies for our project. This is great because it allows us to keep track of what versions of dependencies we use. We could run into problems if we used a version of say Django 1.1 on a project on one computer and then try to work on that same project with Django version 4.0 on another computer. Creating a virtual environment is simple by using the terminal.

Make sure that you're currently in the directory where you want your project to be.  
In the terminal type: `pwd`

This prints the current directory

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679082360948/436612f6-e88d-4ece-af54-20295fb8f64f.png align="left")

I'm currently in my DjangoPlayground folder... seems like as good of a place as any to create a new Django project to me.

![TV gif. Elmo from Sesame Street tilts his head and shrugs as if to say, "I dunno."](https://media2.giphy.com/media/jPAdK8Nfzzwt2/giphy.gif?cid=ecf05e47q6q3scklclx66bamzbjjrl96cd94kd2xxebo5h3z&rid=giphy.gif&ct=g align="center")

Next while in the terminal we'll create a new folder for our project, let's call it *Hello Django*: `$ mkdir helloDjango`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679082766436/0bb54274-284a-4c45-bf03-5323030f2b92.png align="left")

Now that we have a folder created for our project, let's change directories into that folder: `$ cd helloDjango/`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679082870885/8ad0c671-2ffc-41d6-9fe0-c8bf926992d9.png align="center")

In this directory is where we'll create our virtual environment.  
In the terminal type: `$ python -m venv .venv`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679082954989/65588d55-f747-4a5d-9b4f-4d156779dbdf.png align="center")

## **Congratulations**[🥳](https://emojipedia.org/partying-face/)

You've created a brand new Virtual Environment 🖐️🎤

![Muppets gif. Elmo wears a yellow pointed party head, throwing his head back and shaking his bum as he dances.](https://media4.giphy.com/media/v1.Y2lkPTc5MGI3NjExNzM2Y2E1NmM2MzRhMzhkNGQ2ZjE0Y2E1ZmRiMmJiNmEyMmU0N2I0YSZjdD1n/kyLYXonQYYfwYDIeZl/giphy.gif align="center")

Now let's get to work.

### Activating Our Virtual Environment

Now that we've created this virtual environment, we have to activate it. Luckily for us this is easier than it sounds.

While still in the terminal type: `$ source ./.venv/bin/activate`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679084378840/3f47ac45-5ff3-42a4-ae86-ce874caf4f34.png align="center")

That's all... It's activated.  
Notice the `(.venv)`.

We are now inside our *Virtual Environment.*  
Look at this place...so much room for dependencies.

![step brothers bedroom GIF](https://media0.giphy.com/media/yrFrXTTTcHIY0/giphy.gif?cid=ecf05e47mk8f94l1w92eozyn3gnb3bo83k6n72j9joy1bt5i&rid=giphy.gif&ct=g align="center")

### Installing Django

So up to this point, we have created a directory, created our virtual environment inside of that directory, activated our virtual environment, and now it's time for installing Django.

While still in the terminal type: `$ pip install django`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679084885967/f116e511-3ec5-4497-a3dd-77e48a898190.png align="center")

## **Congratulations**[🥳](https://emojipedia.org/partying-face/)

You've installed Django 🖐️🎤

![Muppets gif. Elmo wears a yellow pointed party head, throwing his head back and shaking his bum as he dances.](https://media4.giphy.com/media/v1.Y2lkPTc5MGI3NjExNzM2Y2E1NmM2MzRhMzhkNGQ2ZjE0Y2E1ZmRiMmJiNmEyMmU0N2I0YSZjdD1n/kyLYXonQYYfwYDIeZl/giphy.gif align="center")

But we're not done yet. Let's get to work setting up your very first project.

---

# The Django Project

* Django-Admin
    
* manage. py
    

### Django-Admin

django-admin is Django’s command-line utility for administrative tasks. You can read more about it on [Django's Offical Docs](https://docs.djangoproject.com/en/4.1/ref/django-admin/).

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679086293909/82a162b0-732e-402c-8978-a7e3b6b64dd7.gif align="center")

We're going to use it to create our project called *theHelloDjangoProject.*

While still in the terminal type: `$ django-admin startproject theHelloDjangoProject`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679086476709/ac9cb863-e6e0-45af-b9b0-a6e2dda41197.png align="center")

In the terminal type: `$ ls`

You should see the project that you just created.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679086830359/69d74585-1304-46e0-a3ce-2a2bcfef74dc.png align="left")

Let's take a look inside!  
In the terminal type:  
`$ cd theHelloDjangoProject/`  
`$ ls`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679087013055/8433a6c1-1bc3-4edd-b1e1-2529b88e1367.png align="left")

### manage. py

manage. py is automatically created in each Django project. It does the same thing as django-admin but also sets the DJANGO\_SETTINGS\_MODULE environment variable so that it points to your project’s settings. py file. You can read more about it on [Django's Offical Docs](https://docs.djangoproject.com/en/4.1/ref/django-admin/).

We'll see manage. py again later.  
But before we go, let's run our server.

In the terminal type:  
`$ python manage.py runserver`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679087832616/60c6b780-5b8d-4539-8f99-f96669879d08.png align="center")

We now have our project's server running at: [http://127.0.0.1:8000/](http://127.0.0.1:8000/)

Go ahead... Check it out.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679087886290/91eccd93-c4bc-4f04-be31-240b73111fae.png align="center")

Guess what you JUST DID?!

# You Created Your Very First Django Project

![Blue Collar Work GIF by Pudgy Penguins](https://media2.giphy.com/media/qlKs0m0GxHN6ycbDmV/giphy.gif?cid=ecf05e47ova7qc6s3aqpbtb930k7zh32dfisznry33mjfzp7&rid=giphy.gif&ct=g align="center")

---

# theHelloDjangoApp

Now that we have our project created in the next article, let's go a bit further and create our first 'App'.

![Playing To Be Continued GIF by goodboy noah](https://media1.giphy.com/media/bi2VdYyQvdtjHAOvpG/giphy.gif?cid=ecf05e47eu8xyccjqdr5osdswgvu7kmgac3xne347n1898ge&rid=giphy.gif&ct=g align="center")