Completely updated for Django 4.0! Django for Professionals takes your web development skills to the next level, teaching you how to build production-ready websites with Python and Django. Once you have learned the basics of Django there is a massive gap between building simple "toy apps" and what it takes to build a "production-ready" web application suitable for deployment to thousands or even millions of users. In the book you’ll learn how to: * Build a Bookstore website from scratch * Use Docker and PostgreSQL locally to mimic production settings * Implement advanced user registration with email * Customize permissions to control user access * Write comprehensive tests * Adopt advanced security and performance improvements * Add search and file/image uploads * Deploy with confidence If you want to take advantage of all that Django has to offer, Django for Professionals is a comprehensive best practices guide to building and deploying modern websites. Table of Contents Introduction Prerequisites Book Structure Book Layout Community Conclusion Chapter 1: Initial Set Up The Command Line Install Python 3 Text Editor Install Git Conclusion Chapter 2: Docker Hello, World! What is Docker? Virtual Environments vs Containers Install Docker Docker Hello, World Install Django Django Hello, World Pages App Docker Image Dockerfile .dockerignore docker-compose.yml Git Conclusion Chapter 3: PostgreSQL Django Set Up Docker Detached Mode PostgreSQL docker-compose.yml DATABASES New Database Git Conclusion Chapter 4: Bookstore Project Docker PostgreSQL Custom User Model Custom User Forms Custom User Admin Superuser Tests Unit Tests Git Conclusion Chapter 5: Pages App Templates URLs and Views Tests Testing Templates Testing HTML setUp() Resolve Git Conclusion Chapter 6: User Registration Auth App Auth URLs and Views Homepage Django Source Code Log In Redirects Log Out Sign Up Tests Git Conclusion Chapter 7: Static Assets Local Development STATICFILES_DIRS CSS Images JavaScript Production Bootstrap About Page About Page Tests Django Crispy Forms Git Conclusion Chapter 8: Advanced User Registration django-allauth AUTHENTICATION_BACKENDS EMAIL_BACKEND ACCOUNT_LOGOUT_REDIRECT URLs Templates Log In Log Out Sign Up Admin Email Only Login Tests Social Git Conclusion Chapter 9: Environment Variables Environs SECRET_KEY DEBUG and ALLOWED_HOSTS DATABASES Git Conclusion Chapter 10: Email Custom Confirmation Emails Email Confirmation Page Password Reset and Password Change Email Service Git Conclusion Chapter 11: Books App Models Admin URLs Views Templates object_list Individual Book Page context_object_name Adding URLs get_absolute_url Primary Keys vs. IDs Slugs vs. UUIDs Tests Git Conclusion Chapter 12: Reviews App Foreign Keys Reviews model Admin Templates Tests Git Conclusion Chapter 13: File/Image Uploads Media Files Models Admin Template django-storages Next Steps Git Conclusion Chapter 14: Permissions Logged-In Users Only Permissions Custom Permissions User Permissions PermissionRequiredMixin Groups & UserPassesTestMixin Tests Git Conclusion Chapter 15: Search Search Results Page Basic Filtering Q Objects Forms Search Form Git Conclusion Chapter 16: Performance django-debug-toolbar Analyzing Pages select_related and prefetch_related Indexes Caching Front-end Assets Next Steps Git Conclusion Chapter 17: Security Social Engineering Django updates Deployment Checklist docker-compose-prod.yml DEBUG Defaults SECRET_KEY Web Security SQL injection XSS (Cross Site Scripting) Cross-Site Request Forgery (CSRF) Clickjacking Protection HTTPS/SSL SSL Error HTTP Strict Transport Security (HSTS) Secure Cookies Admin Hardening Git Conclusion Chapter 18: Deployment PaaS vs IaaS WhiteNoise Media Files Gunicorn Heroku Deploying with Docker Heroku Deployment ALLOWED_HOSTS Doing It Live! SECURE_PROXY_SSL_HEADER Production Database Heroku Logs Conclusion Conclusion Learning Resources Feedback