Django In-Depth Series Course
This series covers all key points of the Django framework and can be used as a knowledge base. In other projects, I will reference related chapters as background knowledge. You can read this course in order or jump to specific sections. Each chapter includes code examples.
Basics
Chapter 1: First Look at Django
- 1.1 Hello, Django!
- Web framework concepts
- Django design philosophy (DRY, rapid development)
- Django vs other frameworks comparison
- 1.2 Django Environment Setup
- Python environment requirements
- Virtual environment creation (venv)
- Django 5.x installation
- Recommended development tools
- 1.3 First Django Project
- Create project: django-admin startproject
- Project structure analysis
- Run development server
- Hello World example
Chapter 2: Django MTV Architecture
- 2.1 Django MTV Architecture Pattern
- Model
- Template
- View
- URL configuration
- 2.2 Django Application (App)
- Create app: python manage.py startapp
- App structure
- App registration
- Simple blog app example
Chapter 3: URL Routing System
- 3.1 Django URL Configuration Basics
- URLconf concepts
- path() function
- Path parameter capture
- Regular expression paths
- 3.2 Django Advanced URL Features
- Named URLs and reverse resolution
- URL namespaces
- Include other URLconfs
- Practical example: user profile page routing
Models and Database
Chapter 4: Django Models
- 4.1 Django Model Basics
- ORM concepts
- Define model classes
- Field types explained
- Field options
- 4.2 Django Model Relationships
- One-to-one relationships (OneToOneField)
- One-to-many relationships (ForeignKey)
- Many-to-many relationships (ManyToManyField)
- Blog posts and tags example
- 4.3 Django Model Methods and Attributes
- str method
- Custom methods
- Property decorators
- Meta class options
Chapter 5: Database Operations
- 5.1 Database Configuration
- Supported databases
- Database connection configuration
- Multiple database configuration
- 5.2 Migration System
- makemigrations command
- migrate command
- Migration file analysis
- Data migration example
- 5.3 QuerySet and Database API
- Basic query operations
- Filtering and sorting
- Aggregation and annotation
- Raw SQL queries
- Practical example: article search function
Views and Templates
Chapter 6: Django Views
- 6.1 Django Function Views
- Basic function views
- HttpRequest and HttpResponse
- View decorators
- Error handling
- 6.2 Django Class Views
- View base class
- Generic views concepts
- TemplateView example
- Inheritance and mixins
- 6.3 Django Generic Views Explained
- ListView
- DetailView
- CreateView
- UpdateView
- DeleteView
- Complete CRUD example
Chapter 7: Template System
- 7.1 Django Template Basics
- Template syntax
- Variables and filters
- Tag usage
- Comments
- 7.2 Django Template Inheritance
- Base template creation
- Block tags
- Template inheritance chain
- Practical example: blog layout
- 7.3 Django Custom Templates
- Custom filters
- Custom tags
- Template context processors
- Static file handling
Forms and User Interaction
Chapter 8: Django Forms
- 8.1 Django Form Basics
- Form class definition
- Form field types
- Form validation
- Form rendering
- 8.2 ModelForm
- ModelForm creation
- Field customization
- Data saving
- Contact form example
- 8.3 Advanced Form Features
- Formsets
- Inline formsets
- File upload handling
- CSRF protection
Chapter 9: User Authentication System
- 9.1 Django Authentication Framework
- User model
- Authentication views
- Permission system
- Group management
- 9.2 User Registration and Login
- Registration forms
- Login/Logout views
- Password reset
- Email verification
- 9.3 Permissions and Decorators
- login_required decorator
- Permission checks
- User group permissions
- Custom permissions
Advanced Features
Chapter 10: Django Admin
- 10.1 Admin Basics
- Create superuser
- Register models
- Admin interface customization
- Field display configuration
- 10.2 Advanced Admin Configuration
- List display customization
- Filters and search
- Inline editing
- Custom Admin actions
Chapter 11: Static and Media Files
- 11.1 Static File Management
- STATIC_URL configuration
- collectstatic command
- CSS/JS file organization
- Development vs production environment
- 11.2 Media File Handling
- MEDIA_URL configuration
- File uploads
- Image processing
- File storage backends
Chapter 12: Middleware and Signals
- 12.1 Middleware System
- Middleware concepts
- Built-in middleware
- Custom middleware
- Request/response processing
- 12.2 Django Signals
- Signal system concepts
- Built-in signals
- Custom signals
- Signal handlers
Practical Projects
Chapter 13: Complete Blog System
- 13.1 Project Planning
- Requirements analysis
- Database design
- URL design
- Function module division
- 13.2 Core Function Implementation
- Article CRUD
- Categories and tags
- Comment system
- Search function
- 13.3 Advanced Functions
- User system integration
- Rich text editor
- Cache optimization
- SEO optimization
Chapter 14: API Development
- 14.1 Django REST Framework Introduction
- DRF installation configuration
- Serializers
- API views
- URL routing
- 14.2 RESTful API Design
- API version control
- Authentication and permissions
- Pagination and filtering
- API documentation generation
Deployment and Optimization
Chapter 15: Testing
- 15.1 Unit Testing
- TestCase class
- Database testing
- Form testing
- View testing
- 15.2 Integration Testing
- LiveServerTestCase
- Selenium integration
- Test coverage
- Continuous integration
Chapter 16: Performance Optimization
- 16.1 Database Optimization
- Query optimization
- select_related and prefetch_related
- Database indexing
- Query analysis
- 16.2 Cache System
- Cache framework
- Page caching
- View caching
- Template fragment caching
Chapter 17: Deployment
- 17.1 Production Environment Configuration
- Settings separation
- Environment variables
- Log configuration
- Security settings
- 17.2 Deployment Solutions
- Nginx + Gunicorn
- Cloud platform deployment
- Static file CDN
- Monitoring and maintenance