You are previewing Learning Website Development with Django.
O'Reilly logo
Learning Website Development with Django

Book Description

A beginner's tutorial to building web applications, quickly and cleanly, with the Django application framework

  • Create a complete Web 2.0-style web application with Django

  • Learn rapid development and clean, pragmatic design

  • Build a social bookmarking application

  • No knowledge of Django required

In Detail

Django is a high-level Python web framework that was developed by a fast-moving online-news operation to meet the stringent twin challenges of newsroom deadlines and the needs of web developers. It is designed to promote rapid development and clean, pragmatic design and lets you build high-performing, elegant web applications rapidly. Django focuses on automating as much as possible and adhering to the DRY (Don’t Repeat Yourself) principle, making it easier to build high-performance web applications faster, with less code.

This book will show you how to assemble Django’s features and leverage its power to design, develop, and deploy a fully-featured website. It will walk you through the creation of an example web application, with lots of code. Each chapter will add new features to the site, and show what parts of Django to work on to build these features.

This book has been specifically written for Python developers new to Django, and it’s goal is to help you put together Django applications as quickly as possible. This book will give you clear, concise and, of course, practical guidance to take you from the basics of creating pages with Django through to learning the skills that will make you a Django developer to be reckoned with.

Table of Contents

  1. Learning Website Development with Django
    1. Table of Contents
    2. Learning Website Development with Django
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. Preface
      1. What This Book Covers
      2. Conventions
      3. Reader Feedback
      4. Customer Support
        1. Downloading the Example Code for the Book
        2. Errata
        3. Questions
    7. 1. Introduction to Django
      1. The MVC Pattern in Web Development
      2. Why Python?
      3. Why Django?
        1. Tight Integration between Components
        2. Object-Relational Mapper
        3. Clean URL Design
        4. Automatic Administration Interface
        5. Advanced Development Environment
        6. Multi-Lingual Support
      4. History of Django
      5. Summary
    8. 2. Getting Started
      1. Installing the Required Software
        1. Installing Python
          1. Installing Python on Windows
          2. Installing Python on UNIX/Linux
          3. Installing Python on Mac OS X
        2. Installing Django
          1. Installing Django on Windows
          2. Installing Django on UNIX/Linux and Mac OS X
        3. Installing a Database System
      2. Creating Your First Project
        1. Creating an Empty Project
        2. Setting up the Database
        3. Launching the Development Server
      3. Summary
    9. 3. Building a Social Bookmarking Application
      1. A Word about Django Terminology
      2. URLs and Views: Creating the Main Page
        1. Creating the Main Page View
        2. Creating the Main Page URL
      3. Models: Designing an Initial Database Schema
        1. The Link Data Model
        2. The User Data Model
        3. The Bookmark Data Model
      4. Templates: Creating a Template for the Main Page
      5. Putting It All Together: Generating User Pages
        1. Creating the URL
        2. Writing the View
        3. Designing the Template
        4. Populating the Model with Data
      6. Summary
    10. 4. User Registration and Management
      1. Session Authentication
        1. Creating the Login Page
        2. Enabling Logout Functionality
      2. Improving Template Structure
      3. User Registration
        1. Django Forms
        2. Designing the User Registration Form
      4. Account Management
      5. Summary
    11. 5. Introducing Tags
      1. The Tag Data Model
      2. Creating the Bookmark Submission Form
        1. Restricting Access to Logged-in Users
        2. Methods for Browsing Bookmarks
        3. Improving the User Page
        4. Creating a Tag Page
        5. Building a Tag Cloud
      3. A Word on Security
        1. SQL Injection
        2. Cross-Site Scripting (XSS)
      4. Summary
    12. 6. Enhancing the User Interface with Ajax
      1. Ajax and Its Advantages
      2. Using an Ajax Framework in Django
        1. Downloading and Installing jQuery
      3. The jQuery JavaScript Framework
        1. Element Selectors
        2. jQuery Methods
          1. Hiding and Showing Elements
          2. Accessing CSS Properties and HTML Attributes
          3. Manipulating HTML Documents
          4. Traversing the Document Tree
          5. Handling Events
          6. Sending Ajax Requests
          7. What Next?
      4. Implementing Live Searching of Bookmarks
        1. Implementing Searching
        2. Implementing Live Searching
      5. Editing Bookmarks in Place
        1. Implementing Bookmark Editing
        2. Implementing In-Place Editing of Bookmarks
      6. Auto-Completion of Tags
      7. Summary
    13. 7. Voting and Commenting
      1. Sharing Bookmarks on the Main Page
        1. The SharedBookmark Data Model
        2. Modifying the Bookmark Submission Form
        3. Browsing and Voting for Shared Bookmarks
        4. The Popular Bookmarks Page
      2. Commenting on Bookmarks
        1. Enabling the Comments Application
        2. Creating a View for Comments
        3. Displaying Comments and a Comment Form
        4. Creating Comment Templates
      3. Summary
    14. 8. Creating an Administration Interface
      1. Activating the Administration Interface
      2. Customizing the Administration Interface
        1. Customizing Listing Pages
        2. Overriding Administration Templates
      3. Users, Groups and Permissions
        1. User Permissions
        2. Group Permissions
        3. Using Permissions in Views
      4. Summary
    15. 9. Advanced Browsing and Searching
      1. Adding RSS Feeds
        1. Creating the Recent Bookmarks Feed
          1. Customizing Item Fields
        2. Creating the User Bookmarks Feed
        3. Linking Feeds to HTML Pages
      2. Advanced Searching
        1. Retrieving Objects with the Database API
        2. Advanced Queries with Q Objects
        3. Improving the Search Feature
      3. Organizing Content into Pages (Pagination)
      4. Summary
    16. 10. Building User Networks
      1. Building Friend Networks
        1. Creating the Friendship Data Model
        2. Writing Views to Manage Friends
          1. The Friends List View
          2. Creating the "Add Friend" View
      2. Inviting Friends Via Email
        1. The Invitation Data Model
        2. The "Invite a Friend" Form and View
        3. Handling Activation Links
      3. Improving the Interface with Messages
      4. Summary
    17. 11. Extending and Deploying
      1. Internationalization (i18n)
        1. Marking Strings as Translatable
        2. Creating Translation Files
        3. Enabling and Configuring the i18n System
      2. Improving Performance with Caching
        1. Enabling Caching
          1. Simple Caching
          2. Database Caching
          3. File System Caching
          4. Memcached
        2. Configuring Caching
          1. Caching the Whole Site
          2. Caching Specific Views
      3. Unit Testing
        1. The Test Client
        2. Testing the Registration View
        3. Testing the "Save Bookmark" View
      4. Deploying Django
        1. The Production Web Server
        2. The Production Database
        3. Turning Off Debug Mode
        4. Changing Configuration Variables
        5. Setting Error Pages
      5. Summary
    18. 12. What Next?
      1. Custom Template Tags and Filters
      2. Model Managers and Custom SQL
      3. Generic Views
      4. Contributed Sub-Frameworks
        1. Flatpages
        2. Sites
        3. Markup Filters
        4. Humanize
        5. Sitemaps
        6. Cross-site Request Forgery Protection
      5. Message System
      6. Subscription System
      7. User Scores
      8. Summary
    19. Index