Sams Teach Yourself Django in 24 Hours
by
Brad Dayley
Publisher:
Sams
Pub Date:
February 20, 2008
Print ISBN-10:
0-672-32959-X
Print ISBN-13:
978-0-672-32959-3
eText ISBN-10:
0-7686-8033-6
eText ISBN-13:
978-0-7686-8033-1
Pages:
528
Table of Contents
|
Index
Copyright
About the Author
Acknowledgments
We Want to Hear from You!
Reader Services
Introduction
Who Should Read This Book
How This Book Is Organized
How to Use This Book
Part I: Creating the Website Framework
Hour 1. Understanding Django
What Is Django?
Why Use Django?
Understanding Models
Understanding Views
Understanding Templates
Configuring the settings.py File
Using the manage.py Utility
Understanding the Django Development Server
Understanding the Admin Interface
Installing Django
Summary
Q&A
Workshop
Exercises
Hour 2. Creating Your First Website
Creating a Django Project
Starting the Development Server
Configuring the Database
Installing an Application
Adding Data Using the API
Setting Up the URLConf File
Creating a Simple View
Summary
Q&A
Workshop
Exercises
Hour 3. Adding Models and Objects to Your Website
Installing the Admin Interface Model
Updating the URLconf File to Allow Admin Access
Activating the Model in the Admin Interface
Adding, Modifying, and Viewing Objects in the Admin Interface
Defining Data Models
Summary
Q&A
Workshop
Exercises
Hour 4. Creating the Initial Views
Setting Up the URLconf File
Understanding the HttpRequest and HttpResponse Classes
Configuring the URL Patterns
Adding URL-Based Arguments to the Views
Summary
Q&A
Workshop
Exercises
Part II: Implementing the Website Interface
Hour 5. Using Data from the Database in Views
Adding Data to the Database
Accessing Data in the Database
Modifying Data in the Database
Performing Queries in the Database
Adding Data in a Model to a View
Summary
Q&A
Workshop
Exercises
Hour 6. Configuring Web Page Views
Passing Extra Options to a View
Using View Prefixes
Using Additional URLconf Files
Calling the View Functions Directly
Summary
Q&A
Workshop
Exercises
Hour 7. Implementing Django Templates to Create Custom Views
Configuring the Template Directory
Creating a Template
Rendering a Template as an HTTP Response
Extending Templates
Embedding Templates
Summary
Q&A
Workshop
Exercises
Hour 8. Using Built-in Template Tags to Enhance Views
Implementing Loops
Implementing if Logic
Adding Links with the url Tag
Reducing Code Using the with Tag
Adding Cycle Logic to Tables
Summary
Q&A
Workshop
Exercises
Hour 9. Using Built-in Template Filters to Enhance Views
Understanding Filters
Formatting Text
Manipulating Lists
Sorting Dictionaries
Formatting Dates
Summary
Q&A
Workshop
Exercises
Hour 10. Adding Forms to Views
Creating Form Instances
Rendering Forms as HTML
Rendering Forms from Models
Customizing Forms
Summary
Q&A
Workshop
Exercises
Hour 11. Using Views to Add and Update Data in the Database
Handling GET and POST Requests
Validating Data from a POST Against the Model
Updating Data in the Database
Adding Data to the Database
Summary
Q&A
Workshop
Exercises
Hour 12. Utilizing Generic Views
Understanding Generic Views
Using Simple Generic Views
Displaying an Object List in a Generic View
Displaying Object Details in a Generic View
Displaying Date-Based Objects in a Generic View
Using Generic Object-Creation Views
Using Generic Object-Update Views
Using Generic Object-Deletion Views
Summary
Q&A
Workshop
Exercises
Hour 13. Advanced View Configurations
Loading Templates from Applications
Extending the Template System
Creating Custom Filters
Creating Custom Tags
Understanding How to Use RequestContexts in Templates
Summary
Q&A
Workshop
Exercises
Part III: Implementing a Full-Featured Website
Hour 14. Managing Site Users
Adding Users
Adding Groups
Setting User Permissions
Summary
Q&A
Workshop
Exercises
Hour 15. Adding Website Security
Implementing User Logins
Adding Logout Functionality
Verifying Authentication
Verifying Permissions
Limiting Access to Generic Views
Summary
Q&A
Workshop
Exercises
Hour 16. Managing Sessions and Cookies
Understanding Django's Session Framework
Configuring the Session Manager
Using Django's Test Cookies
Setting and Retrieving Session Data
Setting and Retrieving Cookies
Summary
Q&A
Workshop
Exercises
Hour 17. Customizing Models in the Admin Interface
Customizing the Model Change List
Customizing the Model Form
Viewing Multiple Models Inline
Summary
Q&A
Workshop
Exercises
Hour 18. Customizing the Admin Interface
Overriding Admin Templates at the Site Level
Creating Custom Admin Views
Overriding the Admin Templates at the Application or Object Level
Overriding Block Tags in a Custom Admin Template
Overriding the Built-in Admin Views in the URLconf File
Summary
Q&A
Workshop
Exercises
Part IV: Implementing Advanced Website Components
Hour 19. Implementing Middleware
Installing Middleware
Implementing Middleware Applications
Implementing a Request Preprocessor
Implementing a View Preprocessor
Implementing a Response Postprocessor
Implementing an Exception Postprocessor
Django's Built-in Middleware
Summary
Q&A
Workshop
Exercises
Hour 20. Internationalization and Localization
Localizing Strings in Python
Localizing Strings in Templates
Creating Language Files
Setting Language Preference
Summary
Q&A
Workshop
Exercises
Hour 21. Creating Sitemaps
Creating a Sitemap
Creating a Sitemap of Generic Views
Creating a Sitemap Index
Pinging Google
Summary
Q&A
Workshop
Exercises
Hour 22. Implementing Multiple Websites
Implementing the sites Framework
Using the CurrentSiteManager Class
Summary
Q&A
Workshop
Exercises
Hour 23. Configuring Caching
Configuring Caching Backends
Implementing a Per-Site Cache
Implementing a Per-View Cache
Implementing a Per-Object Cache
Managing Upstream Caching
Summary
Q&A
Workshop
Exercises
Hour 24. Deploying Django
Deploying Django to Apache with mod_python
Other Deployment Configurations
Optimizing Django Deployment
Summary
Q&A
Workshop
Exercises
Appendixes
Appendix A. Django Resources
Django
Python
Python Imaging Library (PIL)
Apache
mod_python
flup
FastCGI
PostgreSQL Database
MySQL
SQLite 3
Microsoft SQL Server
Oracle
Subversion
Appendix B. Django Form Field Objects
Field Objects
Widget Objects
Form Field to Model Field Mapping
Appendix C. Formatting Dates and Times
Try It Yourself
Index