# Django Section of Python-100-Days: Complete 15-Day Learning Path from Basics to Production

> Explore the Django section of Python-100-Days. Master project setup, REST APIs, async tasks, and enterprise caching in 15 days, from basics to production deployment.

- Repository: [骆昊/Python-100-Days](https://github.com/jackfrued/Python-100-Days)
- Tags: tutorial
- Published: 2026-02-24

---

**The Django section of Python-100-Days spans Days 46-60 and delivers a comprehensive curriculum that takes learners from basic project setup to production deployment with REST APIs, asynchronous tasks, and enterprise-grade caching.**

The `jackfrued/Python-100-Days` repository dedicates **15 consecutive days** (Days 46-60) to Django web development, housed entirely within the `Day46-60/` directory. This segment forms a complete, step-by-step learning path that progresses from fundamental MTV architecture to advanced topics like Celery task queues and Nginx deployment. According to the source code, each day is documented in dedicated markdown files containing theory, diagrams, and runnable code examples.

## Day-by-Day Curriculum Breakdown

The Django section follows a pedagogical sequence that builds complexity gradually. Here is the complete 15-day progression:

- **Day 46: Django快速上手** — Covers HTTP basics, MTV pattern, installing Django 2.2.13, project creation via `django-admin startproject`, and the standard layout ([`settings.py`](https://github.com/jackfrued/Python-100-Days/blob/main/settings.py), [`urls.py`](https://github.com/jackfrued/Python-100-Days/blob/main/urls.py), [`wsgi.py`](https://github.com/jackfrued/Python-100-Days/blob/main/wsgi.py)). Introduces app creation with `startapp`, template rendering via `render()`, and the development server.

- **Day 47: 深入模型** — Deep dive into Django ORM, including field types, `makemigrations`, `migrate`, and complex querysets. Located in `Day46-60/47.深入模型.md`.

- **Day 48: 静态资源和 Ajax 请求** — Static file management (`STATIC_URL`, `STATICFILES_DIRS`), media handling, and implementing asynchronous AJAX calls from templates.

- **Day 49: Cookie 和 Session** — State management using cookies, Django’s session middleware, and session backends configuration.

- **Day 50: 制作报表** — Generating PDF and Excel reports using third-party libraries integration.

- **Day 51: 日志和调试工具栏** — Python logging configuration, Django’s LOGGING dictionary setup, and integrating Django Debug Toolbar for performance profiling.

- **Day 52: 中间件的应用** — Writing custom middleware classes, understanding the request/response processing order, and common patterns for authentication and throttling. See `Day46-60/52.中间件的应用.md`.

- **Day 53: 前后端分离开发入门** — Introduction to RESTful design principles and setting up Django REST Framework (DRF) for API-first architecture.

- **Day 54: RESTful 架构和 DRF 入门** — Foundational DRF concepts including serializers, viewsets, routers, and API testing strategies. Located in `Day46-60/54.RESTful架构和DRF入门.md`.

- **Day 55: RESTful 架构和 DRF 进阶** — Advanced DRF features: Token/JWT authentication, permission classes, pagination, and handling nested resources.

- **Day 56: 使用缓存** — Cache backend configuration (local-memory, file-based, Redis) and using the `cache_page` decorator. Configuration examples reside in `Day46-60/56.使用缓存.md`.

- **Day 57: 接入三方平台** — Integrating external APIs for SMS, payment gateways, and cloud storage services.

- **Day 58: 异步任务和定时任务** — Implementing Celery with Redis/RabbitMQ brokers, configuring periodic tasks with `celery beat`, and handling task results. Full coverage in `Day46-60/58.异步任务和定时任务.md`.

- **Day 59: 单元测试** — Writing comprehensive tests using Django’s `TestCase` for models, views, and API endpoints.

- **Day 60: 项目上线** — Production deployment guide covering Gunicorn WSGI server configuration, Nginx reverse proxy setup, static/media file handling, and security hardening. Critical reference file: `Day46-60/60.项目上线.md`.

## Core Technical Components

The curriculum emphasizes **practical implementation** over theory alone. Key technical areas include:

**MTV Architecture** — Detailed explanation of Model-Template-View separation with visual diagrams stored in `Day46-60/res/` showing request/response flow through Django’s core.

**ORM and Database Design** — Comprehensive migration workflows, field relationships (ForeignKey, ManyToMany), and queryset optimization techniques documented in Day 47.

**Middleware Processing** — Custom middleware development covering `__init__`, `__call__`, and process hooks for request/response interception as implemented in Day 52.

**RESTful API Development** — Complete DRF integration spanning basic viewsets (Day 54) to advanced JWT authentication and nested serializers (Day 55).

**Asynchronous Processing** — Celery integration patterns for offloading heavy computations and handling scheduled background tasks (Day 58).

## Code Examples from the Repository

The Django section includes production-ready code snippets illustrating common patterns.

**Creating a project and app:**

```bash
django-admin startproject hellodjango
cd hellodjango
python manage.py startapp first

```

**Basic JSON API view:**

```python

# first/views.py

from django.http import JsonResponse

def api_hello(request):
    return JsonResponse({'msg': 'Hello, Django API!'})

```

**URL configuration:**

```python

# hellodjango/urls.py

from django.urls import path
from first.views import api_hello

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/hello/', api_hello),
]

```

**Template rendering with context:**

```python

# first/views.py

from django.shortcuts import render
from random import sample

def show_index(request):
    fruits = ['Apple', 'Orange', 'Pitaya', 'Durian']
    selected = sample(fruits, 3)
    return render(request, 'index.html', {'fruits': selected})

```

**Redis cache configuration:**

```python

# settings.py

CACHES = {
    'default': {
        'BACKEND': 'django_redis.cache.RedisCache',
        'LOCATION': 'redis://127.0.0.1:6379/1',
    }
}

```

## Visual Learning Resources

The repository supplements text with **architectural diagrams** located in `Day46-60/res/*.png`. These include:

- MTV architecture flowcharts
- HTTP request/response cycle illustrations
- Middleware processing chains
- Django project structure visualizations

These assets are referenced throughout the markdown documentation to clarify abstract concepts like middleware execution order and request routing.

## Summary

The Django section of Python-100-Days provides a **complete full-stack curriculum** within the `Day46-60/` directory.

- Covers 15 progressive topics from basic setup (Day 46) to production deployment (Day 60)
- Includes enterprise patterns: DRF for APIs, Celery for async tasks, Redis caching, and custom middleware
- Provides runnable code examples for project initialization, view creation, and caching configuration
- Contains visual diagrams in `Day46-60/res/` explaining Django’s internal architecture
- Ends with production hardening guides using Gunicorn and Nginx

## Frequently Asked Questions

### What Django version does Python-100-Days use?

The curriculum specifically uses **Django 2.2.13** as noted in `Day46-60/46.Django快速上手.md`. While some syntax may work in newer versions, the examples and project structure target this LTS release.

### Does the Django section cover REST API development?

Yes. Days 53-55 form a complete **Django REST Framework (DRF)** tutorial. Day 53 introduces RESTful concepts, Day 54 covers serializers and viewsets in `54.RESTful架构和DRF入门.md`, and Day 55 advances to JWT authentication and permissions.

### How does the curriculum handle background tasks?

Day 58 (`58.异步任务和定时任务.md`) dedicates an entire lesson to **Celery integration**. It covers broker configuration (Redis/RabbitMQ), task result backends, and setting up periodic tasks with `celery beat` for scheduled execution.

### Is production deployment covered in the Django section?

Yes. Day 60 (`60.项目上线.md`) provides a complete **production deployment guide** including Gunicorn WSGI server setup, Nginx reverse proxy configuration, static/media file handling via `collectstatic`, and security hardening techniques for live environments.