Django
Hi Djangonauts! And welcome to my Django notes, all about the web framework for perfectionists with deadlines 🤌
Django’s philosophy is centered on the principles of rapid development, clean and pragmatic design, and the “don’t repeat yourself” (DRY) principle.
When building a large database-driven application, I would honestly pay to use Django.
Django follows the “Batteries included” philosophy and provides almost everything developers might want to do “out of the box”. Because everything you need is part of the one “product”, it all works seamlessly together, follows consistent design principles, and has extensive and up-to-date documentation.
With around 10 lines of code I get GET
, POST
, PUT
, PATCH
, and DELETE
API endpoints for any DB table normalised into clean consistent formats, with proper status codes, proper exceptions, throttling, permissions (per user, per object, e.t.c), are browsable, easy to document, and all the other good stuff that proper APIs should have. 🙌 🔥
Quick Docs đź“—
Introduction
- Setting Up a Django Project
- Apps and Project Structure
- Django Admin Interface
- URL Routing and Configuration
Models
- Defining Models
- Model Fields
- Model Methods
- Model Meta Options
- Model Inheritance
- Model Migrations
- Relationships (OneToOne, ManyToMany, ForeignKey)
Queries
- Creating Queries
- QuerySets
- Field Lookups
- Query Expressions
- Complex Lookups
- Aggregation and Annotation
Views
- Function-Based Views (FBVs)
- Class-Based Views (CBVs)
- Generic Views
- Mixins
- Handling Requests and Responses
Authentication
- User Authentication and Authorization
- Password Management
- User Registration
- Permissions and Groups
Middleware
- Understanding Middleware
- Built-in Middleware
- Custom Middleware
Advanced Topics
- Signals
- Caching
- Sessions
- Environment Variables and Secret Keys
- Internationalization and Localization
- Management Commands
- Asynchronous Views
- Working with Databases (Other than SQLite)
- Custom User Models
- Security Best Practices
Testing
- Writing and Running Tests
- Testing Tools and Libraries
- Testing Models, Views, and Forms
- Using the Django Test Client
Deployment
- Deployment Checklist
- Deploying with WSGI
- Deploying to AWS (Elastic Beanstalk, EC2)
- Using Docker with Django
- Setting Up CI/CD
- N+1 Query Problem
- Query Optimization
- Using Django Debug Toolbar
- Database Indexing
- Profiling and Monitoring
Best Practices
- Project Structure and Organization
- Code Quality and Style Guides
- Documentation Practices
- Security Best Practices
- Maintaining Django Projects
Django Rest Framework (DRF)
Why DRF ?? đź’ˇ
DRF Basics
- Creating a Simple API
- Requests
- Responses
Views
- Function-Based Views (FBVs) in DRF
- Class-Based Views (CBVs) in DRF
- ViewSets and Routers
- API Views
- Generic Views
- Mixins
Serializers
- Understanding Serializers
- ModelSerializers
- Serializer Fields
- Validations and Validators
- Custom Serializers
- Nested Serializers
Routers
- SimpleRouter
- DefaultRouter
- Custom Routers
Authentication and Permissions
- Authentication in DRF
- Token Authentication
- Session Authentication
- OAuth2 with Django OAuth Toolkit
- Custom Authentication
- Permission Classes
- Object-Level Permissions
- Custom Permissions and Roles
Throttling
- Understanding Throttling
- Built-in Throttling Classes
- Custom Throttling
- Pagination in DRF
- Built-in Pagination Classes
- Custom Pagination
Filtering, Searching, and Ordering
- Filtering in DRF
- DjangoFilterBackend
- SearchFilter
- OrderingFilter
- Custom Filters
Versioning
- Understanding API Versioning
- URL Path Versioning
- Host Name Versioning
- Query Parameter Versioning
- Accept Header Versioning
Content Negotiation
- Understanding Content Negotiation
- Media Types
- Custom Content Negotiation
Testing
- Testing DRF APIs
- Using DRF’s APIClient
- Testing Serializers
- Testing Views and ViewSets
Advanced Topics
- Hyperlinked APIs
- API Documentation with DRF (Swagger)
- Rate Limiting
- Asynchronous Views with Django Channels
- Using WebSockets with DRF
Misc
- Uploading Images
Best Practices
- Structuring DRF Projects
- Writing Clean and Maintainable Code
- Security Best Practices for DRF
- Documentation Practices for APIs
- Maintaining DRF Projects
Django Auditlog
Nothing to see here yet
DRF Spectacular
Nothing to see here yet
Channels and WebSockets
Nothing to see here yet
Graphene (GraphQL)
Nothing to see here yet
Django-Ninja
Nothing to see here yet