Book Image

Django 1.0 Website Development

Book Image

Django 1.0 Website Development

Overview of this book

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 (17 chapters)
Django 1.0 Web Site Development
Credits
About the author
About the reviewer
Preface

Message system


Our application allows users to add each other as friends and monitor friend bookmarks. Although these two forms of communication are related to the nature of our bookmarking application, sometimes users want the flexibility of sending private messages to each other. This feature is especially useful for enhancing the social aspect of our web site.

The message system can be implemented in a variety of ways. It can be as simple as providing each user with a contact form, which works by sending its content to the user's email when it is submitted. You already have all of the information needed to build the components of this functionality:

  • A message form with a text field for the subject, and a text area for the body of the message

  • A view that displays the message form of a user and sends the contents of the form to the user via the send_mail function

When allowing users to send emails via your site, you need to be careful in order to prevent abuse of the feature. Here you can restrict...