Python Web Development with Django®

Developer's Library

Jeff Forcier, Paul Bissex, Wesley Chun

Publisher: Addison-Wesley, 2009, 377 pages

ISBN: 0-13-235613-9

Keywords: Python, Web Programming

Last modified: Aug. 15, 2009, 1:01 a.m.

Using the simple, robust, Python-based Django framework, you can build powerful Web solutions with remarkably few lines of code. In Python Web Development with Django®, three experienced Django and Python developers cover all the techniques, tools, and concepts you need to make the most of Django 1.0, including all the major features of the new release.

The authors teach Django through in-depth explanations, plus provide extensive sample code supported with images and line-by-line explanations. You’ll discover how Django leverages Python’s development speed and flexibility to help you solve a wide spectrum of Web development problems and learn Django best practices covered nowhere else. You’ll build your first Django application in just minutes and deepen your real-world skills through start-to-finish application projects including

  • Simple Web log (blog)
  • Online photo gallery
  • Simple content management system
  • Ajax-powered live blogger
  • Online source code sharing/syntax highlighting tool
  • How to run your Django applications on the Google App Engine

This complete guide starts by introducing Python, Django, and Web development concepts, then dives into the Django framework, providing a deep understanding of its major components (models, views, templates), and how they come together to form complete Web applications. After a discussion of four independent working Django applications, coverage turns to advanced topics, such as caching, extending the template system, syndication, admin customization, and testing. Valuable reference appendices cover using the command-line, installing and configuring Django, development tools, exploring existing Django applications, the Google App Engine, and how to get more involved with the Django community.

    • Introduction
    • Where Web Frameworks Come From
    • A Better Way
    • We're Not in Kansas Anymore
    • Web Development is Better with Python and Django
  1. Getting Started
    1. Practical Python for Django
      • Python Skills Are Django Skills
      • Getting Started: Python's Interactive Interpreter
      • Python Basics
        • Comments
        • Variables and Assignment
        • Operators
      • Python Standard Types
        • Object Boolean Values
        • Numbers
        • Numeric Operators
        • Numeric Built-in and Factory Functions
        • Sequences and lterables
        • Lists
        • Strings
        • Sequence Built-ins and Factory Functions
        • Mapping Type: Dictionaries
        • Standard Type Summary
      • Flow Control
        • Conditionals
        • Loops
      • Exception Handling
        • The finally Clause
        • Throwing Exceptions with raise
      • Files
      • Functions
        • Declaring and Calling Functions
        • Functions Are First-Class Objects
        • Anonymous Functions
        • *args and **kwargs
        • Decorators
      • Object-Oriented Programming
        • Class Definitions
        • Instantiation
        • Subclassing
        • Inner Classes
      • Regular Expressions
        • The re module
        • Searching Versus Matching
      • Common Gotchas
        • Single-Item Tuples
        • Modules
        • Mutability
        • Constructor Versus Initializer
      • Coding Style (PEP 8 and Beyond)
        • Indent Four Spaces
        • Use Spaces and Not Tabs
        • Don't Write Single-Line Suites on the Same Line as the Header
        • Create Documentation Strings (aka docstrings'')
      • Summary
    2. Django for the Impatient: Building a Blog
      • Creating the Project
      • Running the Development Server
      • Creating the Blog Application
      • Designing Your Model
      • Setting Up the Database
        • Using a Database Server
        • Using SQLite
        • Creating the Tables
      • Setting Up the Automatic admin Application
      • Trying Out the admin
      • Making Your Blog's Public Side
        • Creating a Template
        • Creating a View Function
        • Creating a URL Pattern
      • Finishing Touches
        • Template Niceties
        • Date-Based Ordering
        • Timestamp Formatting Via a Template Filter
      • Summary
    3. Starting Out
        • Dynamic Web Site Basics
        • Communication: HTTP, URLs, Requests, Responses
        • Data Storage: SQL and Relational Databases
        • Presentation: Rendering Templates into HTML and Other Formats
        • Putting it All Together
      • Understanding Models, Views, and Templates
        • Separating the Layers (MVC)
        • Models
        • Views
        • Templates
      • Overall Django Architecture
      • Core Philosophies of Django
        • Django Tries to Be Pythonic
        • Don't Repeat Yourself (DRY)
        • Loose Coupling and Flexibility
        • Rapid Development
      • Summary
  2. Django in Depth
    1. Defining and Using Models
      • Defining Models
        • Why Use an ORM?
        • Django's Rich Field Types
        • Relationships Between Models
        • Model Inheritance
        • Meta Inner Class
        • Admin Registration and Options
      • Using Models
        • Creating and Updating Your Database Using manage.py
        • Query Syntax
        • Utilizing SQL Features Django Doesn't Provide
      • Summary
    2. URLs, HTTP Mechanisms, and Views
      • URLs
        • Introduction to URLconfs
        • Replacing Tuples with url
        • Using Multiple patterns Objects
        • Including Other URL Files with include
        • Function Objects Versus Function-Name Strings
      • Modeling HTTP: Requests, Responses, and Middleware
        • Request Objects
        • Response Objects
        • Middleware
      • Views/Logic
        • Just Python Functions
        • Generic Views
        • Semi-generic Views
        • Custom Views
      • Summary
    3. Templates and Form Processing
      • Templates
        • Understanding Contexts
        • Template Language Syntax
      • Forms
        • Defining Forms
        • Filling Out Forms
        • Validation and Cleaning
        • Form Display
        • Widgets
      • Summary
  3. Django Applications by Example
    1. Photo Gallery
      • The Model
      • Preparing for File Uploads
      • Installing PIL
      • Testing ImageField
      • Building Our Custom File Field
        • Initialization
        • Adding Attributes to the Field
        • Saving and Deleting the Thumbnail
      • Using ThumbnailImageField
      • Setting Up DRY URLs
      • The Item App's URL Layout
      • Tying it All Together with Templates
      • Summary
    2. Content Management System
      • What's a CMS?
      • The Un-CMS: Flatpages
        • Enabling the Flatpages App
        • Flatpage Templates
        • Testing it Out
      • Beyond Flatpages: A Simple Custom CMS
        • Making the Model
        • Imports
        • Completing the Model
        • Controlling Which Stories Are Viewed
        • Working with Markdown
        • URL Patterns in urls.py
        • Admin Views
        • Displaying Content Via Generic Views
        • Template Layout
        • Displaying Stories
        • Adding Search
        • Managing Users
        • Supporting Workflow
      • Possible Enhancements
      • Summary
    3. Liveblog
      • What Exactly is Ajax?
        • Why Ajax is Useful
      • Planning the Application
        • Choosing an Ajax Library
      • Laying Out the Application
      • Putting the Ajax In
        • The Basics
        • The X'' in Ajax (Or XML Versus JSON)
        • Installing the JavaScript Library
        • Setting Up and Testing jQuery
        • Creating the View Function
        • Using the View Function Via JavaScript
      • Summary
    4. Pastebin
      • Defining the Model
      • Creating the Templates
      • Designing the URLs
      • Trying It Out
      • Limiting Number of Recent Pastes Displayed
      • Syntax Highlighting
      • Cleanup Via Cron Job
      • Summary
  4. Advanced Django Techniques and Features
    1. Advanced Django Programming
      • Customizing the Admin
        • Changing Layout and Style Using
        • Fieldsets
        • Extending the Base Templates
        • Adding New Views
        • Authentication Decorators
      • Using Syndication
        • The Feed Class
        • Giving the Feed a URL
        • Doing More with Feeds
      • Generating Downloadable Files
        • Nagios Configuration Files
        • vCard
        • Comma-Separated Value (CSV)
        • Charts and Graphs Using PyCha
      • Enhancing Django's ORM with Custom Managers
        • Changing the Default Set of Objects
        • Adding New Manager Methods
      • Extending the Template System
        • Simple Custom Template Tags
        • Inclusion Tags
        • Custom Filters
        • More Complex Custom Template Tags
        • Alternative Templating
      • Summary
    2. Advanced Django Deployment
      • Writing Utility Scripts
        • Cronjobs for Cleanup
        • Data Import/Export
      • Customizing the Django Codebase itself
      • Caching
        • A Basic Caching Recipe
        • Caching Strategies
        • Caching Backend Types
      • Testing Djanto Applications
        • Doctest Basics
        • Unittest Basics
        • Running Tests
        • Testing Models
        • Testing Your Entire Web App
        • Testing the Django Codebase Itself
      • Summary
  5. Appendices
    1. Command Line Basics
      • Putting the Command'' in Command Line''
      • Options and Arguments
      • Pipes and Redirection
      • Environment Variables
      • The Path
      • Summary
    2. Installing and Running Django
      • Python
        • Mac OS X
        • Unix/Linux
        • Windows
        • Updating Your Path
        • Testing
        • Optional Add-ons
      • Django
        • Packaged Releases
        • Development Version
        • Installation
        • Testing
      • Web Server
        • The Built-In Server: Not for Production
        • The Standard Approach: Apache and mod_python
        • The Flexible Alternative: WSGI
        • Another Approach: Flup and FastCGI
      • SQL Database
        • SQLite
        • PostgreSQL
        • MySQL
        • Oracle
        • Other Databases
      • Summary
    3. Tools for Practical Django Development
      • Version Control
        • The Trunk and Branches
        • Merging
        • Centralized Version Control
        • Decentralized Version Control
        • Version Control for Your Project
      • Project Management Software
        • Trac
      • Text Editors
        • Emacs
        • Vim
        • TextMate
        • Eclipse
    4. Finding, Evaluating, and Using Django
      • Applications
      • Where to Look for Applications
      • How to Evaluate Applications
      • How to Use Applications
      • Sharing Your Own Application
    5. Django on the Google App Engine
      • Why the App Engine Matters
      • Pure Google App Engine Applications
      • Limitations of the App Engine Framework
      • Google App Engine Helper for Django
        • Getting the SDK and the Helper
        • More on the Helper
      • Integrating the App Engine
        • Copying the App Engine Code to Your
        • Project
        • Integrating the App Engine Helper
        • Porting Your Application to App Engine
        • Taking a Test Drive
        • Adding Data
      • Creating a New Django Application That
      • Runs on App Engine
      • Summary
      • Online Resources
    6. Getting Involved in the Django Project

Reviews

Python Web Development with Django®

Reviewed by Roland Buresund

Very Good ******** (8 out of 10)

Last modified: Aug. 15, 2009, 1:01 a.m.

A very good introduction to Django, if you're coming from outside the Django community. It is easily read, covers a lot of ground, but fails to live up to its promise in that you will know how to do ceratin stuff in Django after reading it, but you will not understand why!

All in all, very worth reading if you want to understand the hoopla about Django (even for old PHP/CMS users). And it manages to introduce you to the GAE as well, so good luck!

Comments

There are currently no comments

New Comment

required

required (not published)

optional

required

captcha

required