Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Django 1.0 Website Development
Django 1.0 Website Development

Django 1.0 Website Development: Build powerful web applications, quickly and cleanly, with the Django application framework

$25.99 $17.99
Book Mar 2009 272 pages 1st Edition
eBook
$25.99 $17.99
Print
$43.99
Subscription
$15.99 Monthly
eBook
$25.99 $17.99
Print
$43.99
Subscription
$15.99 Monthly

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Mar 10, 2009
Length 272 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781847196781
Category :
Table of content icon View table of contents Preview book icon Preview Book

Django 1.0 Website Development

Chapter 1. Introduction to Django

Welcome! This book is about Django, an open source web framework that enables you to build clean and feature-rich web applications with minimal time and effort. Django is written in Python, a general purpose language that is well-suited for developing web applications. Django loosely follows a model-view-controller design pattern, which greatly helps in building clean and maintainable web applications.

This chapter gives you an overview of the technologies used in this book. The chapters that follow will take you through a tutorial for building a social bookmarking application from the group using Django.

In this introduction, you will read about the following:

  • The MVC pattern in web development

  • Why we should use Python

  • Why we should use Django

  • The history of Django

MVC pattern in web development


Web development has made great progress during the last few years. It began as a tedious task that involved using a protocol called Common Gateway Interface (CGI) for interfacing external programs with the web server. The CGI applications used standard I/O facilities available to the C programming language in order to manually parse user input and produce page output. In addition to being difficult to work with, CGI required a separate copy of the program to be launched for each request. This used to quickly overwhelm servers.

Next, scripting languages were introduced to web development, and this inspired developers to create more efficient technologies. Languages such as Perl and PHP quickly made their way into the world of web development. As a result, common web tasks such as cookie handling, session management, and text processing became much easier. Although scripting languages included libraries to deal with day-to-day web-related tasks, they lacked unified frameworks, as libraries were usually disparate in design, usage, and conventions. Therefore, the need for cohesive frameworks arose.

A few years ago, the model-view-controller (MVC) pattern for web-based applications was introduced. This software engineering pattern separates data (model), user interface (view), and data-handling logic (controller) so that one can be changed without affecting the others. The benefits of this pattern are obvious. With it, designers can work on the interface without worrying about data storage or management. Developers are able to program the logic of data handling without getting into the details of presentation. As a result, the MVC pattern quickly found its way into web languages, and serious web developers started to embrace it in preference to previous techniques.

The following diagram illustrates how each of the components of the MVC pattern interacts with each other to serve a user request:

Why Python?


Python is a general purpose programming language. Although it is used for a wide variety of applications, Python is very suitable for developing web applications. It has a clean and elegant syntax. It is supported by a large library of standard and contributed modules, which covers everything from multi-threading to the zipping of files. The language's object-oriented model is especially suited for MVC style development.

Sooner or later, performance will become a major concern with web projects. Python's runtime environment shines here, as it is known to be fast and stable. Python supports a wide range of web servers through modules, including the famous Apache. Furthermore, it is available for all the major platforms: UNIX/Linux, Windows, and Mac. Python also supports a wide array of database servers, but you won't have to deal directly with them. Django provides a unified layer of access to all available database engines, as we will see later.

Python is a free software that you can download and freely use from http://python.org/. You are even allowed to distribute it without having to pay any fees. Access to the source code is available to those who want to add features or fix bugs. As a result, Python enjoys a large community of developers who quickly fix bugs and introduce new features.

Python is very easy to learn, and it is being adopted in many universities as the first programming language to be taught. Although this book assumes working knowledge of Python, advanced features will be explained as they are used. If you want to refresh your Python knowledge, you are recommended to read the official Python tutorial available at http://python.org/doc/ before continuing with this book.

To sum up, Python was chosen over many other scripting languages for this book. The reasons are:

  • A clean and elegant syntax

  • A large standard library of modules that covers a wide range of tasks

  • Extensive documentation

  • A mature runtime environment

  • Support for standard and proven technologies such as Linux and Apache

    Note

    If you want to learn more about Python and its features, these are two excellent sources: the official Python web site at http://python.org/ and the Python book Dive Into Python (freely available at http://www.diveintopython.org/).

Why Django?


Since the spread of the MVC pattern into web development, Python has provided quite a few choices when it comes to web frameworks such as Django, TurboGears, and Zope. Although choosing one out of many can be confusing initially, having several competing frameworks can only be a good thing for the Python community. That's because it drives the development of all the frameworks further and provides a rich set of options to choose from.

Django is one of the available frameworks for Python, so the question is: What sets it apart to become the topic of this book, and what makes it popular in the Python community? The next subsections will answer these questions by providing an overview of the main advantages of Django.

Tight integration between components

First of all, Django provides a set of tightly integrated components. All of these components have been developed by the Django team. Django was originally developed as an in-house framework for managing a series of news-oriented web sites. Later, its code was released on the Internet, and the Django team continued its development using the open source model. Because of its roots, Django's components were designed for integration, reusability, and speed from the start.

Object-Relational Mapper

Django's database component, the Object-Relational Mapper (ORM), provides a bridge between the data model and the database engine. It supports a large set of database systems, and switching from one engine to another is a matter of changing a configuration file. This gives the developer great flexibility if a decision is made to change from one database engine to another.

Clean URL design

The URL system in Django is very flexible and powerful. It lets you define patterns for the URLs in your application and define Python functions to handle each pattern. This enables developers to create URLs that are both user and search engine friendly.

Automatic administration interface

Django comes with an administration interface that is ready to be used. This interface makes the management of your application's data a breeze. It is also highly flexible and customizable.

Advanced development environment

In addition, Django provides a very nice development environment. It comes with a lightweight web server for development and testing. When the debugging mode is enabled, Django provides very thorough and detailed error messages with a lot of debugging information. All of this makes isolating and fixing bugs very easy.

Multilingual support

Django supports multilingual web sites through its built-in internationalization system. This can be very valuable for those working on web sites with more than one language. The system makes translating the interface a very simple task.

The standard features expected of a web framework are all available in Django. These include the following:

  • A template and text filtering engine with simple, but extensible syntax

  • A form generation and validation API

  • An extensible authentication system

  • A caching system for speeding up the performance of applications

  • A feed framework for generating RSS feeds

Even though Django does not provide a JavaScript library to simplify working with AJAX, choosing one and integrating it with Django is a straightforward matter, as we will see in later chapters.

So to conclude, Django provides a set of integrated and mature components with excellent documentation at http://www.djangoproject.com/documentation/, thanks to its large community of developers and users. With Django available, there has never been a better time to start learning a web development framework!

History of Django


Django started as an internal project at the Lawrence Journal-World newspaper in 2003. Often, the web development team there had to implement new features or even entire applications within hours. Therefore, Django was created to meet the fast deadlines of journalism web sites, while at the same time keeping the development process clean and maintainable. By the summer of 2005, Django became mature enough to handle several high-traffic sites, and the developers decided to release it to the public as an open source project. The project was named after the jazz guitarist, Django Reinhardt.

Now that Django is an open source project, it has gathered developers and users from all over the world. Bug fixes and new features are introduced on a daily basis, and the original development team keeps an eye on the whole process to make sure that Django remains what it is meant to be—a web framework for building clean, maintainable, and reusable web applications.

Summary


Web development has made large leaps of progress over the last few years. The advent of scripting languages, web frameworks, and AJAX made rapid development of web applications possible and easier than ever. This book takes you through a tutorial for building a Web 2.0 application using two hot technologies: Python and Django. The application allows users to store and share bookmarks. Many of the exciting Web 2.0 applications will be explained and developed throughout this book.

In the next chapter, we will set up our development environment by installing the necessary software, and get a feel for Django by creating our first application.

Left arrow icon Right arrow icon

Key benefits

  • 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

Description

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.

What you will learn

Register your users through a user authentication system and manage them efficiently Restrict user access to certain pages and protect against malicious input Create tags to allow site visitors to classify, view, and share content easily Create your own administration interface for proper monitoring of the web site Enhance your user interface with AJAX and add flavors to your web site Enable voting and commenting on content, and display popular content to site visitors Build user networks; add friend management and invitation features for social networking Create unit tests to automate the testing of code

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Mar 10, 2009
Length 272 pages
Edition : 1st Edition
Language : English
ISBN-13 : 9781847196781
Category :

Table of Contents

17 Chapters
Django 1.0 Web Site Development Chevron down icon Chevron up icon
Credits Chevron down icon Chevron up icon
About the author Chevron down icon Chevron up icon
About the reviewer Chevron down icon Chevron up icon
Preface Chevron down icon Chevron up icon
Introduction to Django Chevron down icon Chevron up icon
Getting Started Chevron down icon Chevron up icon
Building a Social Bookmarking Application Chevron down icon Chevron up icon
User Registration and Management Chevron down icon Chevron up icon
Introducing Tags Chevron down icon Chevron up icon
Enhancing the User Interface with AJAX Chevron down icon Chevron up icon
Voting and Commenting Chevron down icon Chevron up icon
Creating an Administration Interface Chevron down icon Chevron up icon
Advanced Browsing and Searching Chevron down icon Chevron up icon
Building User Networks Chevron down icon Chevron up icon
Extending and Deploying Chevron down icon Chevron up icon
What Next? Chevron down icon Chevron up icon

Customer reviews

Filter icon Filter
Top Reviews
Rating distribution
Empty star icon Empty star icon Empty star icon Empty star icon Empty star icon 0
(0 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 0%
1 star 0%

Filter reviews by


No reviews found
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.