Django - The Easy Way A step-by-step guide on building Django websites Samuli Natri © 2017 - 2018 Samuli Natri Table of Contents 1. Foreword About This Book Code Blocks Editors, Code Hosting & Operating System About The Author 2. New Project 3. Base App, PyCharm And Homepage PyCharm For Django Base App Base Template Home URL Home View Home Template & Inheritance 4. Version Control With GIT (Optional) .gitignore file First Commit Bitbucket & SSH Key New Repository Push 5. CSS Styling, Gulp, SASS CSS Vanilla CSS Gulp SASS 6. Header And Footer Markup Styling 7. Breakpoints And Main Menu Mixins Responsive Layout Main Menu 8. JavaScript And Dropdown Menu Dropdown Markup Dropdown Styling Dropdown JavaScript 9. Blog Posts Post Model Makemigrations & Migrate Models & Database Admin Post View Post Urls Post Template H1 & Title Tags Post Styling 10. Responsive And Reusable Grid Grid Template Grid Styling Hide Main Container 11. Reusable Pagination Paginator Class Simple Example More Complex Example Pagination Styling 12. Thumbnails Imagekit Package Thumbnail Generation 13. Tags And Relationships Tag Model & ManyToManyField Post Page Tags Tag View Tag Grid Tag Styling 14. Custom Post Form ModelForm Post Form Template Post Form Urls Forms.py Post Form Views Form Styling Add Post Link 15. Custom Search Search App Search Templates Search View Search Urls Search Styling 16. Authentication Account Urls Account Templates Register & Class Based Views Login & Logout Links Styling 17. Profile Model And Displayname Profile Model & OneToOneField Displayname & Admin Inline Fields Author Field & ForeignKey Update Custom Form 18. Profile Page Profile View Profile Template Profile Urls Profile Styling Profile Links Login & Logout Urls 19. Permissions And Decorators Editor Group Decorators Edit Post Link 20. Extend User Forms CustomUserCreationForm CustomUserChangeForm Profile Page Links 21. Test Driven Development Functional Tests VS Unit Tests Selenium & Geckodriver Functional Tests Unit Tests Feedback Items Testing Models Testing Views Testing Forms 22. Translation i18n_patterns About Page Makemessages & Compilemessages Language Switcher 23. Custom Error Pages Settings Template Files 24. Deployment Digitalocean Droplet Unix User Freeze Requirements Clone To Production Virtual Environment Settings File Test With Runserver & Links PostgreSQL Static & Media Files Nginx Setup Gunicorn Monitor Gunicorn Password Protection With .htpasswd Deploy Changes Settings For Production 25. Initial Data With Fixtures Dump Data Load Data 26. Domain Namecheap Nginx 27. HTTPS And Nginx Let’s Encrypt Firewall 28. Send Email Setup Mailbox Email Logging In Localhost 29. Caching Installation Configuration 30. Afterword Congratulations! Where To Go Next? 1. Foreword About This Book This book is a practical guide on how to build Django applications. We will build a blog from start to finnish. Each new feature that we add introduces a new concept. We cover topics from basic concepts like Models and Views all the way to test driven development and deployment. By the end of this book you will have deployed a responsive, cached website to a production server and learned how to update it. The focus is on Django topics. This is not a Python, HTML, CSS or JavaScript book. Those will be covered minimally. Code Blocks Sometimes long lines have extra backslashes (“\”) that have been added automatically. Make sure not to include those. New inserts and changes in code are marked with bold text: INSTALLED_APPS = [ ... 'django.contrib.staticfiles', 'base', 'blog', ] Editors, Code Hosting & Operating System I would recommend starting with an editor that is easy to get into like “Atom” (https://atom.io/) so you don’t have to fight the tool while learning Django. Check also PyCharm Community Edition (https://www.jetbrains.com/pycharm/). It’s a free tool for Python development. My alltime favourite is Emacs (https://www.gnu.org/software/emacs/) but it requires some work for it to be comfortable to use. With server operations I usually use “Vim” (https://www.vim.org/) but Nano (https://www.nano-editor.org/) might be more suitable for beginners. You can install it like this: sudo apt-get update sudo apt-get install nano You can use “BitBucket” (https://bitbucket.org/) to host your code repository for free. Checkout also GitHub (https://github.com/) and GitLab (https://about.gitlab.com/). I’m using “macOS” but the development process is pretty much the same with all operating systems. The differences are mainly manifesting in terminal operations. For example in macOS you would activate virtual environment like this “source venv/bin/activate” but in Windows you run the .bat executable “venv\Scripts\activate.bat”. About The Author
Description: