Book description
Django is an amazingly powerful system for creating modern, dynamic websites. But programming Django hasn’t always been easy–until now. Django Unleashed is your step-by-step, beginner-friendly guide to leveraging Django’s core capabilities and its powerful contributed library. You’ll learn in the most effective way possible: hands on, by building a fully functional Django website from scratch. You’ll even deploy the website to the cloud.
As you build your website, expert Django consultant and trainer Andrew Pinkham reveals how websites operate; how Django makes building websites easy; how to write Python code that leverages its immense capabilities; and how to build solutions that are robust, reliable, and secure. You’ll start simply and learn to solve increasingly challenging problems: mastering new features and understanding how Django’s architecture shapes their behavior, and gaining essential knowledge for working with any web framework, not just Django.
Drawing on his extensive experience teaching Django, Pinkham answers the key questions beginners ask most often. And as you gain experience, you’ll learn advanced techniques for enhancing site functionality and performance, strengthening security, promoting code reuse, and much more.
Detailed information on how to…
Quickly start a new Django project and establish a strong foundation for a growing site
Define how your data is organized and create a SQLite database to manage it
Quickly produce HTML with Django templates
Create dynamic webpages with Django’s URL patterns and views, including function views, class-based views, and generic views
Enable efficient, reliable data input with Django Forms and custom form validations
Understand the Model-View-Controller (MVC) architecture, compare it to Model-Template-Views, and gain a holistic understanding of Django’s structure
Write as little code as possible, simplify code reuse, and mitigate software decay by adhering to the Don’t Repeat Yourself paradigm.
Dive into Django source code to troubleshoot problems
Extend site functionality with Django’s contributed library
Protect your site with user authentication and permissions
Avoid security pitfalls such as SQL Injection, XSS, and CSRF
Optimize site performance
Deploy your site to a managed cloud service and to a PostgreSQL database
Table of contents
- Title Page
- Copyright Page
- Contents
- Preface
- Acknowledgments
- About the Author
- We Want to Hear from You!
- Reader Services
-
I: Django’s Core Features
- 1. Starting a New Django Project: Building a Startup Categorizer with Blog
- 2. Hello World: Building a Basic Webpage in Django
-
3. Programming Django Models and Creating a SQLite Database
- 3.1 Introduction
- 3.2 Why Use a Database?
- 3.3 Organizing Our Data
- 3.4 Specifying and Organizing Data in Django Using Models
- 3.5 Using Django to Automatically Create a SQLite Database with manage.py
- 3.6 Manipulating Data in the Database: Managers and QuerySets
- 3.7 String Case Ordering
- 3.8 Putting It All Together
-
4. Rapidly Producing Flexible HTML with Django Templates
- 4.1 Introduction
- 4.2 Revisiting Hello World: The Advantages of Templates
- 4.3 Understanding Django Templates and Their Goals
- 4.4 Choosing a Format, an Engine, and a Location for Templates
- 4.5 Building a First Template: A Single Tag Object
- 4.6 Building the Rest of Our App Templates
- 4.7 Using Template Inheritance for Design Consistency
- 4.8 Using Templates in Python with the Template, Context, and loader Classes
- 4.9 Putting It All Together
-
5. Creating Webpages with Controllers in Django: Views and URL Configurations
- 5.1 Introduction
- 5.2 The Purpose of Views and URL Configurations
- 5.3 Step-by-Step Examination of Django’s Use of Views and URL Configurations
- 5.4 Building Tag Detail Webpage
- 5.5 Generating 404 Errors for Invalid Queries
- 5.6 Shortening the Development Process with Django View Shortcuts
- 5.7 URL Configuration Internals: Adhering to App Encapsulation
- 5.8 Implementing the Views and URL Configurations to the Rest of the Site
- 5.9 Class-Based Views
- 5.10 Redirecting the Homepage
- 5.11 Putting It All Together
- 6. Integrating Models, Templates, Views, and URL Configurations to Create Links between Webpages
-
7. Allowing User Input with Forms
- 7.1 Introduction
- 7.2 Django Forms as State Machines
-
7.3 Creating TagForm, a Form for Tag Objects
- 7.3.1 Implementing the save() Method for TagForm
- 7.3.2 Using TagForm in the Django Shell
- 7.3.3 Form Validation Techniques in Django
- 7.3.4 Creating a Clean Method for the Tag Model name Field
- 7.3.5 Preparing to Build a Clean Method for the Tag Model slug Field
- 7.3.6 Creating a Clean Method for the Tag Model slug Field
- 7.3.7 Using ModelForm Inheritance to Connect TagForm to Tag
- 7.3.8 Understanding ModelForm Validation
- 7.3.9 Updating Objects with ModelForm
- 7.4 Building the Forms for Startup, Newslink, and Post Models
- 7.5 Putting It All Together
-
8. Displaying Forms in Templates
- 8.1 Introduction
- 8.2 Creating a New Template to Create Tag Objects
- 8.3 Creating a New Template to Update Tag Objects
- 8.4 Creating a New Template to Delete Tag Objects
- 8.5 Creating Templates for StartupForm, NewsLinkForm, and PostForm
- 8.6 Reconsidering Template Inheritance
- 8.7 Putting It All Together
- 9. Controlling Forms in Views
- 10. Revisiting Migrations
- 11. Bending the Rules: The Contact Us Webpage
- 12. The Big Picture
-
II: Django’s Contributed Libraries
- 13. Django’s Contributed Library
- 14. Pagination: A Tool for Navigation
- 15. Creating Webpages with Django Flatpages
- 16. Serving Static Content with Django
- 17. Understanding Generic Class-Based Views
-
18. Advanced Generic Class-Based View Usage
- 18.1 Introduction
- 18.2 Rapid Review of GCBV
- 18.3 Globally Setting Template Suffix for Update Views
- 18.4 Generating Pagination Links
- 18.5 Re-creating PostDetail with DateDetailView
- 18.6 Switching to GCBVs with PostGetMixin in Post Views
- 18.7 Making PostGetMixin Generic
- 18.8 Fixing NewsLink URL Patterns and Form Behavior
- 18.9 Putting It All Together
- 19. Basic Authentication
- 20. Integrating Permissions
- 21. Extending Authentication
- 22. Overriding Django’s Authentication with a Custom User
- 23. The Admin Library
-
III: Advanced Core Features
- 24. Creating Custom Managers and Querysets
- 25. Handling Behavior with Signals
-
26. Optimizing Our Site for Speed
- 26.1 Introduction
- 26.2 Profiling
-
26.3 Limiting Database Queries
- 26.3.1 Understanding the Problem
- 26.3.2 Template Short-Circuiting
- 26.3.3 Caching Properties
- 26.3.4 Caching Template Variables
- 26.3.5 Introspecting Optimization in the Shell
- 26.3.6 Using Migrations to Learn about Optimization
- 26.3.7 Optimizing Views with Related Content
- 26.3.8 Optimizing Manager and QuerySet Classes Directly
- 26.3.9 Optimizing Admin Pages
- 26.4 Changing Database Behavior Internally
- 26.5 Changing Performance Globally
- 26.6 Putting It All Together
- 27. Building Custom Template Tags
- 28. Adding RSS and Atom Feeds and a Sitemap
- 29. Deploy!
- 30. Starting a New Project Correctly
- IV: Appendixes
- Index
- Code Snippets
Product information
- Title: Django Unleashed
- Author(s):
- Release date: November 2015
- Publisher(s): Sams
- ISBN: 9780133812497
You might also like
book
Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow, 3rd Edition
Through a recent series of breakthroughs, deep learning has boosted the entire field of machine learning. …
book
Python Crash Course, 2nd Edition
This is the second edition of the best selling Python book in the world. Python Crash …
book
Hands-On Machine Learning with Scikit-Learn, Keras, and TensorFlow, 2nd Edition
Through a series of recent breakthroughs, deep learning has boosted the entire field of machine learning. …
book
Python for Excel
While Excel remains ubiquitous in the business world, recent Microsoft feedback forums are full of requests …