# 🚀 Day 1: Getting Started with Django – Beginner's Web Dev Series

Welcome to **Day 1 of our 10-day Django Workshop**! 🎉  
If you’re new to Django and looking for a fast-track way to build secure, scalable web applications using Python, you’re in the right place.

In this post, we’ll cover the basics and help you create your **first Django project** and **application** — with hands-on coding. Let’s dive in.

---

## 📌 What is Django?

**Django** is a high-level Python web framework that enables rapid development of secure and maintainable websites. It takes care of much of the hassle of web development so you can focus on writing your app without reinventing the wheel.

> ✅ Built by developers, for developers  
> ✅ Follows the **Model-View-Template (MVT)** architecture  
> ✅ Includes built-in admin panel, authentication, ORM, routing, and more

---

## 💡 Why Django?

* ⚡ **Fast Development:** Less code, more productivity.
    
* 🔐 **Secure:** Prevents common threats like CSRF, XSS, SQL Injection.
    
* 🛠️ **Batteries Included:** Comes with most things pre-built.
    
* 🔁 **DRY Principle:** Don’t Repeat Yourself — write reusable, clean code.
    
* 🌐 **Scalable:** Trusted by startups and large enterprises alike.
    

---

## 🌍 Who Uses Django?

Many tech giants and platforms started or still run on Django:

* Instagram
    
* Pinterest
    
* Mozilla Firefox
    
* Disqus
    
* Bitbucket
    
* Karobar
    

Django powers apps with millions of users — so yes, it’s production ready!

---

## ⚙️ Setting Up Django in 3 Steps

### ✅ 1. Install Python (Skip if already installed)

Visit [https://python.org](https://python.org/) and install Python 3.13.3.

### ✅ 2. Create a Virtual Environment

```bash
python3 -m venv .venv
source .venv/bin/activate  # On Windows: env\Scripts\activate
```

### ✅ 3. Install Django

```bash
pip install django
```

Confirm installation:

```bash
django-admin --version
```

🎉 Done! Let’s build something real.

---

## 📁 Creating Your First Django Project

Run this command in your terminal:

```bash
django-admin startproject mysite
cd mysite
```

This creates the following structure:

```plaintext
mysite/
├── manage.py
└── mysite/
    ├── __init__.py
    ├── settings.py
    ├── urls.py
    ├── asgi.py
    └── wsgi.py
```

## 📁 Understanding the folder structure

* [`manage.py`](http://manage.py)`: Command-line utility to manage the project`
    
* `__init__.py: Marks the folder as a Python package`
    
* [`settings.py`](http://settings.py)`: Configuration for the entire project`
    
* [`urls.py`](http://urls.py)`: Maps URLs to views and routes requests`
    
* [`wsgi.py`](http://wsgi.py)`: WSGI entry point used by servers (like Gunicorn or Django's dev server)`
    
* [`asgi.py`](http://asgi.py)`: ASGI entry point for async servers (e.g., WebSockets)`
    

---

## 🧱 Create Your First Django App

Inside your project folder:

```bash
python manage.py startapp homepage
```

Update `settings.py` to include the new app:

```python
INSTALLED_APPS = [
    ...,
    'homepage',
]
```

Now you have a reusable app where you’ll build features.

---

## 🧠 What is a View in Django?

A **view** is a Python function that takes a web request and returns a web response.

Let’s create a simple view in `homepage/views.py`:

```python
from django.http import HttpResponse

def index(request):
    return HttpResponse("Welcome to Django Workshop!")
```

---

## 🔗 Hooking Up URLs

### Step 1: Create a new file `homepage/urls.py`:

```python
from django.urls import path
from . import views

urlpatterns = [
    path('', views.index, name='index'),
]
```

### Step 2: Connect it to the project-level `mysite/urls.py`:

```python
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('homepage.urls')),
]
```

---

## 🌐 Run Your Django Server

Fire up the dev server:

```bash
python manage.py runserver
```

Visit `http://127.0.0.1:8000/` and you’ll see:

> **Welcome to Django Workshop!**

You just built your first Django page 🎉

---

## 🛠️ Your Turn: Day 1 Challenge

Create your first Django project from scratch:

* Project name: `mywebsite`
    
* App name: `homepage`
    
* Build a view that returns: **"Day 1 challenge completed!"**
    
* Configure the app and route it correctly to show the message in the browser.
    

---

## 📚 Coming Up Next…

Tomorrow we’ll cover:

* Detailed url routing
    
* Understanding Views(Function Based)
    
* Introduction to Templates
    
* Static files and Media files
