You are previewing Practical Django Projects, Second Edition.
O'Reilly logo
Practical Django Projects, Second Edition

Book Description

Practical Django Projects introduces this popular framework by way of a series of real-world projects. Readers follow along with the development of each project, implementing and running each application while learning new features along the way. This edition is updated for Django 1.1 and includes and includes an all-new chapter covering practical development tools and techniques you'll be able to apply to your own development workflow.

Table of Contents

  1. Copyright
  2. About the Author
  3. About the Technical Reviewer
  4. Introduction
  5. 1. Welcome to Django
    1. 1.1. What's a Web Framework and Why Should I Want One?
    2. 1.2. Saying Hello to Django
    3. 1.3. Saying Hello to Python
    4. 1.4. Installing Django
    5. 1.5. Taking Your First Steps with Django
    6. 1.6. Exploring Your Django Project
    7. 1.7. Looking Ahead
  6. 2. Your First Django Site: A Simple CMS
    1. 2.1. Configuring Your First Django Project
    2. 2.2. Putting Together the CMS
    3. 2.3. Introducing the Django Template System
    4. 2.4. Looking Ahead
  7. 3. Customizing the Simple CMS
    1. 3.1. Adding Rich-Text Editing
    2. 3.2. Adding a Search System to the CMS
    3. 3.3. Improving the Search View
    4. 3.4. Improving the Search Function with Keywords
    5. 3.5. Looking Ahead
  8. 4. A Django-Powered Weblog
    1. 4.1. Compiling a Feature Checklist
    2. 4.2. Writing a Django Application
      1. 4.2.1. Projects vs. Applications
      2. 4.2.2. Standalone and Coupled Applications
    3. 4.3. Creating the Weblog Application
    4. 4.4. Designing the Models
    5. 4.5. Building the Entry Model
      1. 4.5.1. Basic Fields
      2. 4.5.2. Slugs, Useful Defaults, and Uniqueness Constraints
      3. 4.5.3. Authors, Comments, and Featured Entries
      4. 4.5.4. Different Types of Entries
      5. 4.5.5. Categorizing and Tagging Entries
      6. 4.5.6. Writing Entries Without Writing HTML
      7. 4.5.7. Finishing Touches
    6. 4.6. The Weblog Models So Far
    7. 4.7. Writing the First Views
    8. 4.8. Using Django's Generic Views
    9. 4.9. Decoupling the URLs
    10. 4.10. Looking Ahead
  9. 5. Expanding the Weblog
    1. 5.1. Writing the Link Model
    2. 5.2. Views for the Link Model
    3. 5.3. Setting Up Views for Categories
    4. 5.4. Using Generic Views (Again)
    5. 5.5. Views for Tags
    6. 5.6. Cleaning Up the URLConf Module
    7. 5.7. Handling Live Entries
    8. 5.8. Looking Ahead
  10. 6. Templates for the Weblog
    1. 6.1. Dealing with Repetitive Elements: The Power of Inheritance
      1. 6.1.1. How Template Inheritance Works
      2. 6.1.2. Limits of Template Inheritance
    2. 6.2. Defining the Base Template for the Blog
    3. 6.3. Setting Up Section Templates
    4. 6.4. Displaying Archives of Entries
      1. 6.4.1. Entry Index
      2. 6.4.2. Yearly Archive
      3. 6.4.3. Monthly and Daily Archives
      4. 6.4.4. Entry Detail
    5. 6.5. Defining Templates for Other Types of Content
    6. 6.6. Extending the Template System with Custom Tags
      1. 6.6.1. How a Django Template Works
      2. 6.6.2. A Simple Custom Tag
      3. 6.6.3. Writing a More Flexible Tag with Arguments
      4. 6.6.4. Writing the LatestContentNode
      5. 6.6.5. Registering and Using the New Tag
    7. 6.7. Looking Ahead
  11. 7. Finishing the Weblog
    1. 7.1. Comments and django.contrib.comments
    2. 7.2. Implementing Model Inheritance and Abstract Models
    3. 7.3. Installing the Comments Application
      1. 7.3.1. Performing Basic Setup
      2. 7.3.2. Retrieving Lists of Comments for Display
    4. 7.4. Moderating Comments
      1. 7.4.1. Using Signals and the Django Dispatcher
    5. 7.5. Building the Automatic Comment Moderator
      1. 7.5.1. Adding Akismet Support
      2. 7.5.2. Sending E-mail Notifications
      3. 7.5.3. Using Django's Comment-Moderation Features
    6. 7.6. Adding Feeds
      1. 7.6.1. Creating the LatestEntriesFeed Class
      2. 7.6.2. Generating Entries by Category: A More Complex Feed Example
    7. 7.7. Looking Ahead
  12. 8. A Social Code-Sharing Site
    1. 8.1. Compiling a Feature Checklist
    2. 8.2. Setting Up the Application
    3. 8.3. Building the Initial Models
    4. 8.4. The Language Model
    5. 8.5. The Snippet Model
    6. 8.6. Testing the Application
    7. 8.7. Building Initial Views for Snippets and Languages
    8. 8.8. CSS for pygments Syntax Highlighting
    9. 8.9. Views for Languages
    10. 8.10. An Advanced View: Top Authors
    11. 8.11. Improving the View of Top Authors
    12. 8.12. Adding a top_languages View
    13. 8.13. Looking Ahead
  13. 9. Form Processing in the Code-Sharing Application
    1. 9.1. A Brief Tour of Django's Form System
      1. 9.1.1. A Simple Example
      2. 9.1.2. Validating the Username
      3. 9.1.3. Validating the Password
      4. 9.1.4. Creating the New User
      5. 9.1.5. How Form Validation Works
      6. 9.1.6. Processing the Form
    2. 9.2. Writing a Form for Adding Code Snippets
      1. 9.2.1. Writing a View to Process the Form
      2. 9.2.2. Writing the Template to Handle the add_snippet View
    3. 9.3. Automatically Generating the Form from a Model Definition
    4. 9.4. Simplifying Templates That Display Forms
    5. 9.5. Editing Snippets
    6. 9.6. Looking Ahead
  14. 10. Finishing the Code-Sharing Application
    1. 10.1. Bookmarking Snippets
    2. 10.2. Adding Basic Bookmark Views
    3. 10.3. Creating a New Template Tag: {% if_bookmarked %}
      1. 10.3.1. Parsing Ahead in a Django Template
      2. 10.3.2. Resolving Variables Inside a Template Node
    4. 10.4. Using RequestContext to Automatically Populate Template Variables
    5. 10.5. Adding the User Rating System
      1. 10.5.1. Rating Snippets
      2. 10.5.2. Adding an {% if_rated %} Template Tag
      3. 10.5.3. Retrieving a User's Rating
    6. 10.6. Looking Ahead
  15. 11. Practical Development Techniques
    1. 11.1. Using Version-Control Systems to Track Your Code
      1. 11.1.1. A Simple Example
      2. 11.1.2. Version-Control Tools and Hosting Options
      3. 11.1.3. Choosing and Using a VCS
    2. 11.2. Using Isolated Python Environments to Manage Software
    3. 11.3. Using Build Tools
    4. 11.4. Using a Deployment Tool
    5. 11.5. Simplifying Your Django Development Process
      1. 11.5.1. Living Without Projects
      2. 11.5.2. Using Relative Paths in Settings
      3. 11.5.3. Dealing with Settings That Change for Different Environments
      4. 11.5.4. Unit-Testing Your Applications
    6. 11.6. Looking Ahead
  16. 12. Writing Reusable Django Applications
    1. 12.1. One Thing at a Time
      1. 12.1.1. Staying Focused
      2. 12.1.2. Advantages of Tightly Focused Applications
    2. 12.2. Developing Multiple Applications
      1. 12.2.1. Drawing the Lines Between Applications
      2. 12.2.2. Splitting Up the Code-Sharing Application
    3. 12.3. Building for Flexibility
      1. 12.3.1. Flexible Form Handling
      2. 12.3.2. Flexible Template Handling
      3. 12.3.3. Flexible Post-Form Processing
      4. 12.3.4. Flexible URL Handling
      5. 12.3.5. Taking Advantage of Django's APIs
      6. 12.3.6. Staying Generic
    4. 12.4. Distributing Django Applications
      1. 12.4.1. Python Packaging Tools
      2. 12.4.2. Writing a setup.py Script with distutils
      3. 12.4.3. Standard Files to Include in a Package
      4. 12.4.4. Documenting an Application
    5. 12.5. Looking Ahead