Django - The Easy Way (2nd Edition)
Django - The Easy Way (2nd Edition)
$39.00
Minimum price
$39.00
Suggested price
Django - The Easy Way (2nd Edition)

This book is 100% complete

Completed on 2018-12-16

About the Book

"Django - The Easy Way (2nd Edition)" book is a practical, step-by-step guide on how to build Django websites. You can find full source code in here: https://samuli.to/Django-The-Easy-Way-Source.

Django is a Python based open source web development framework that has been around since 2005. It enables you to create complex database-driven websites while keeping things decoupled and dry. The Python Package Index (PyPI) hosts numerous free packages that can be used to extend projects without re-inventing the wheel. Django is used by some well-known sites like Instagram, Bitbucket and Disqus.

About this book

This book is about learning the Django web framework with simple, practical examples. It guides you through all the main concepts one at the time. We will work on many small projects rather than working on a single big application through the book. This helps digesting the information as the projects have less distracting code from previous chapters. By the end of the book you should have a solid understanding of how to build and deploy apps with Django.

Who is this book for?

This book is suitable for beginner to intermediate level web developers. You don't have to have any experience with Django or building web applications in general. We start with the very basics and increase complexity as we go along.

What this book is NOT about?

We use Bootstrap 4 to have a decent looking testing playground but otherwise frontend concepts are covered minimally. This is not a book about Python, HTML, CSS or JavaScript. Basic knowledge about those technologies would be helpful but is not required for the book. The focus is on the Django web framework core concepts and deployment practices.

How this book is organized

This book is organized in 32 chapters that focus on key concepts of the framework. I recommend reading the book in sequence, starting from the very beginning and working your way to the end from there.

Chapters 1-7

Chapters 1-7 cover how to install Python and use virtual environments.

Chapters 8-10

In chapters 8-10 we create a simple Django project and examine the project structure. "Hello world" project introduces the reader to views, paths and templates.

Chapters 11-13

Chapters 11-13 cover how the template inheritance works and how to integrate Bootstrap 4 frontend framework with Django. We also apply custom styles with CSS (Cascading Style Sheets).

Chapters 14-16

Chapters 14-16 cover how to use models and interact with a database. We learn about filters and how to build a base project that can be used as a starting point for other projects. We create a detail page and learn how to work with slugs and reverse URLS.

Chapters 17-20

In chapters 17-20 we learn how to categorise items with a ForeignKey field and tag items with a ManyToManyField. We do lookups through relationships, re-use templates and build a minimalistic search feature.

Chapters 21-24

Chapters 21-24 show how to create forms with ModelForm. We customize the forms by changing field order and render validation errors manually. The Python interactive interpreter is used to manipulate objects and interact with Django.

Chapters 25-26

Chapters 25-26 cover how to create a complete authentication system with the Allauth package and how to theme the default forms with Bootstrap 4. User authorization is managed with groups and decorators.

Chapters 27-28

In chapters 27-28 we upload images and serve them from a local media folder. Bootstrap 4 is used to create a grid view to display the images. The uploaded images are compressed to thumbnails using the ImageKit package.

Chapters 29-32

Chapters 29-32 show how to deploy to Heroku platform and serve static assets and user-uploaded files from an Amazon AWS bucket. We learn how to establish continuous deployment workflows with Heroku pipelines and send emails with SendGrid.

  • Share this book

About the Author

Table of Contents

  • Preface
  • About this book
    • Who is this book for?
    • What this book is NOT about?
    • How this book is organized
      • Chapters 1-7
      • Chapters 8-10
      • Chapters 11-13
      • Chapters 14-16
      • Chapters 17-20
      • Chapters 21-24
      • Chapters 25-26
      • Chapters 27-28
      • Chapters 29-32
    • About the author
  • 1. Installing Python on Windows
    • 1.1 Downloading and installing Python
    • 1.2 Using the interactive prompt
    • 1.3 Details
      • 1.3.1 Python interpreter
    • 1.4 Summary
  • 2. Installing Python on macOS
    • 2.1 Downloading and installing Python
    • 2.2 Using the interactive prompt
    • 2.3 Details
      • 2.3.1 Python interpreter
    • 2.4 Summary
  • 3. Installing Python on Linux
    • 3.1 Installing Python
    • 3.2 Using the interactive prompt
    • 3.3 Details
      • 3.3.1 Python interpreter
    • 3.4 Summary
  • 4. Creating virtual environments in Windows
    • 4.1 Creating and activating virtual environments
    • 4.2 Summary
  • 5. Creating virtual environments in macOS
    • 5.1 Creating and activating virtual environments
    • 5.2 Summary
  • 6. Creating virtual environments in Linux
    • 6.1 Creating and activating virtual environments
    • 6.2 Summary
  • 7. Virtual environments and pip
    • 7.1 Why use virtual environments?
    • 7.2 Details
      • 7.2.1 Organizing folders
      • 7.2.2 Freezing requirements
      • 7.2.3 Excluding venv from the repository
      • 7.2.4 Using other tools
      • 7.2.5 Using python vs python3
    • 7.3 Summary
  • 8. Creating a Django project
    • 8.1 Setup
    • 8.2 Creating a new Project
    • 8.3 Running the development server
    • 8.4 Details
    • 8.5 Summary
  • 9. Creating a Hello World app
    • 9.1 Setup
    • 9.2 Creating apps
    • 9.3 Creating template files
    • 9.4 Creating views
    • 9.5 Adding a homepage path
    • 9.6 Summary
  • 10. Examining the project structure and apps
    • 10.1 Adding features with apps
    • 10.2 Exploring the project structure
    • 10.3 Exploring the project package
    • 10.4 Summary
  • 11. Working with template inheritance
    • 11.1 Setup
    • 11.2 Creating a base app
    • 11.3 Extending templates
    • 11.4 Details
    • 11.5 Summary
  • 12. Installing Bootstrap 4 theme
    • 12.1 Setup
    • 12.2 Modifying an existing template
    • 12.3 Updating the homepage template
    • 12.4 Details
    • 12.5 Summary
  • 13. Managing static files
    • 13.1 Setup
    • 13.2 Creating a stylesheet file
    • 13.3 Details
      • 13.3.1 Working with static files
      • 13.3.2 Using the static tag
      • 13.3.3 Forcing cache refresh with versioning
    • 13.4 Summary
  • 14. Creating models
    • 14.1 Setup
    • 14.2 Creating the Flower model
    • 14.3 Listing flowers
    • 14.4 Details
      • 14.4.1 Explaining models
      • 14.4.2 Returning a string representation
      • 14.4.3 Making database queries
    • 14.5 Summary
  • 15. Creating a base project
    • 15.1 Setup
    • 15.2 Adding a description field
    • 15.3 Adding masonry like columns
    • 15.4 Adding a footer
    • 15.5 Summary
  • 16. Creating a detail page
    • 16.1 Setup
    • 16.2 Adding a detail page path
    • 16.3 Creating the detail view
    • 16.4 Creating the detail page template
    • 16.5 Creating slugs
    • 16.6 Updating the path
    • 16.7 Defining get_absolute_url() method
    • 16.8 Using url tag
    • 16.9 Details
      • 16.9.1 Capturing URL values
      • 16.9.2 Using view parameters
      • 16.9.3 Explaining slugs
      • 16.9.4 Reversing URLS
    • 16.10 Summary
  • 17. Adding category as a many-to-one relationhip
    • 17.1 Setup
    • 17.2 Adding category field and model
    • 17.3 Updating the homepage template
    • 17.4 Details
      • 17.4.1 Examining many-to-one relationships
      • 17.4.2 Accessing related objects
    • 17.5 Summary
  • 18. Referencing tags with a ManyToMany field
    • 18.1 Setup
    • 18.2 Adding the tags field
    • 18.3 Updating the homepage template
    • 18.4 Summary
  • 19. Creating a tags page
    • 19.1 Setup
    • 19.2 Adding tags path
    • 19.3 Adding the slug field
    • 19.4 Creating the tags view
    • 19.5 Updating the homepage template
    • 19.6 Details
      • 19.6.1 Doing lookups across relationships
      • 19.6.2 Reusing templates
    • 19.7 Summary
  • 20. Creating a search feature
    • 20.1 Setup
    • 20.2 Adding a search form
    • 20.3 Updating the index view
    • 20.4 Details
    • 20.5 Summary
  • 21. Working with forms: creating items
    • 21.1 Setup
    • 21.2 Creating the edit form
    • 21.3 Creating the form class
    • 21.4 Updating urlpatterns
    • 21.5 Creating the view function
    • 21.6 Adding a menu item
    • 21.7 Details
      • 21.7.1 Protecting against cross site request forgeries
      • 21.7.2 Adding form fields
      • 21.7.3 Using the Form class
      • 21.7.4 Examining the view function
    • 21.8 Summary
  • 22. Working with forms: editing items
    • 22.1 Setup
    • 22.2 Adding the path
    • 22.3 Creating the edit view
    • 22.4 Updating the edit link
    • 22.5 Details
      • 22.5.1 Capturing the id
      • 22.5.2 Examining the edit view
    • 22.6 Summary
  • 23. Working with forms: customization
    • 23.1 Setup
    • 23.2 Adding the description field
    • 23.3 Details
      • 23.3.1 Changing field order
      • 23.3.2 Customizing validation errors
    • 23.4 Summary
  • 24. Creating and deleting objects
    • 24.1 Setup
    • 24.2 Adding the delete path
    • 24.3 Adding the delete view
    • 24.4 Updating the delete link
    • 24.5 Details
    • 24.6 Summary
  • 25. Authenticating users with Allauth
    • 25.1 Setup
    • 25.2 Installing Allauth
    • 25.3 Creating template files
    • 25.4 Updating the templates for Bootstrap 4
    • 25.5 Details
      • 25.5.1 Configuration options
      • 25.5.2 Adding the paths
      • 25.5.3 django-widget-tweaks
    • 25.6 Summary
  • 26. Authorization
    • 26.1 Setup
    • 26.2 Adding the Editor group
    • 26.3 Creating a test user
    • 26.4 Using permissions
    • 26.5 Using decorators
    • 26.6 Details
      • 26.6.1 Authentication vs authorization
      • 26.6.2 Controlling access with decorators
    • 26.7 Summary
  • 27. Creating an image gallery
    • 27.1 Setup
    • 27.2 Installing pillow
    • 27.3 Configuring media variables
    • 27.4 Adding ImageField
    • 27.5 Adding images to flowers
    • 27.6 Using the static helper function
    • 27.7 Adding the grid
    • 27.8 Details
    • 27.9 Summary
  • 28. Adding image thumbnails
    • 28.1 Setup
    • 28.2 Installing ImageKit
    • 28.3 Adding the thumbnail field
    • 28.4 Details
    • 28.5 Summary
  • 29. Deploying on Heroku
    • 29.1 Setup
    • 29.2 Creating a Heroku app
    • 29.3 Installing Heroku CLI
      • 29.3.1 Installation in Windows
      • 29.3.2 Installation in macOS
      • 29.3.3 Installation in Ubuntu
      • 29.3.4 Authenticating with a browser
    • 29.4 Creating a Procfile
    • 29.5 Updating the settings.py file
    • 29.6 Creating the repository
    • 29.7 Pushing changes
    • 29.8 Updating the database
    • 29.9 Summary
  • 30. Using Amazon AWS to serve files
    • 30.1 Setup
    • 30.2 Creating an Amazon AWS bucket
    • 30.3 Setting up permissions
    • 30.4 Updating settings.py file
    • 30.5 Adding an image field to the Post model
    • 30.6 Installing packages
    • 30.7 Summary
  • 31. Setting up Heroku pipelines
    • 31.1 Setup
    • 31.2 Creating a GitHub repository
    • 31.3 Creating a pipeline
    • 31.4 Testing deployment
    • 31.5 Adding a production app
    • 31.6 Enabling review apps
    • 31.7 Using pull requests
    • 31.8 Deleting the branch
    • 31.9 Summary
  • 32. Sending emails with SendGrid
    • 32.1 Creating an account
    • 32.2 Summary
  • Licenses

The Leanpub 45-day 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Write and Publish on Leanpub

Authors, publishers and universities use Leanpub to publish amazing in-progress and completed books and courses, just like this one. You can use Leanpub to write, publish and sell your book or course as well! Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks. Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. It really is that easy.

Learn more about writing on Leanpub