You are previewing Django 1.0 Web Site Development.
O'Reilly logo
Django 1.0 Web Site Development

Book Description

Build powerful web applications, quickly and cleanly, with the Django application framework

  • Teaches everything you need to create a complete Web 2.0-style web application with Django 1.0

  • Learn rapid development and clean, pragmatic design

  • No knowledge of Django required

  • Packed with examples and screenshots for better understanding

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 take advantage of its power to design, develop, and deploy a fully-featured web site. It will walk you through the creation of an example web application, with lots of code examples.

Specially revised for version 1.0 of Django, the book starts by introducing the main design concepts in Django. Next, it leads you through the process of installing Django on your system. After that, you will start right away on building your social bookmarking application using Django. Various Django 1.0 components and sub-frameworks will be explained during this process, and you will learn about them by example.

In each chapter, you will build one or more of the features that are essential in Web 2.0 applications, like user management, tags, and AJAX. You will also learn about good software development practices, such as keeping your application secure, and automating testing with unit tests. By the end of the book, you will have built a fully functional real-life Web 2.0 application, and learned how to deploy it to a production server.

Table of Contents

  1. Django 1.0 Web Site Development
    1. Django 1.0 Web Site Development
    2. Credits
    3. About the author
    4. About the reviewer
    5. Preface
      1. What this book covers
      2. Who this book is for
      3. Conventions
      4. Reader feedback
      5. Customer support
        1. Downloading the example code for the book
        2. Errata
        3. Piracy
        4. Questions
    6. 1. Introduction to Django
      1. 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. Multilingual support
      4. History of Django
      5. Summary
    7. 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
    8. 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
    9. 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
    10. 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
    11. 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 basic searching
        2. Implementing live searching
      5. Editing bookmarks in place
        1. Implementing basic bookmark editing
        2. Implementing in-place editing of bookmarks
      6. Auto-completion of tags
      7. Summary
    12. 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
    13. 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
    14. 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
    15. 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
    16. 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. Local memory 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
        4. The test client
        5. Testing the registration view
      3. Deploying Django
        1. The production web server
        2. The production database
        3. Turning off debug mode
        4. Changing configuration variables
        5. Setting error pages
      4. Summary
    17. 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 (CSRF)
      5. Message system
      6. Subscription system
      7. User scores
      8. Summary