Introduction

Pro Django represents seven years of accumulated knowledge in Python and Django, designed to educate readers who are already familiar with both topics and would like to take them further than they had previously done. You will learn a wide range of advanced techniques available in both Python and Django, along with tips on how to use them to achieve advanced functionality.

This book is designed to be both a narrative to be read from start to finish and a general reference to be searched for specific information. Since you may not know what to look for or where to find it yet, feel free to read through the book first, then keep it handy for refreshing your memory as necessary.

What This Book Is Not

There are plenty of resources available for learning Python and Django, so this book does not strive to teach the basics. For readers new to Python, I highly recommend Dive Into Python 3 by Mark Pilgrim (Apress, 2009). For learning Django, I’d recommend The Definitive Guide to Django: Web Development Done Right by Adrian Holovaty and Jacob Kaplan-Moss (Second Edition, Apress, 2009). Additionally, Practical Django Projects by James Bennett (Second Edition, Apress, 2009) is an excellent resource for general application development.

Who This Book Is For

Because Pro Django doesn’t dwell on introductory details, readers will be expected to have experience with both Python and Django. If you’re new to either subject, please consider one of the books mentioned in the previous section before trying to tackle this book.

Even if you’ve only experimented on your own without launching a full site yet, a basic familiarity should be sufficient. You don’t need to be an expert to start reading Pro Django, but you might be by the time you finish.

Interpreting Code Samples

Pro Django uses a simple format, interleaving explanations of Python’s and Django’s available features with code that demonstrates their use in the real world. There are two types of code samples used, which differ in how they should be executed.

Python’s interactive interpreter is a great way to test out small pieces of code and see how it works in a variety of situations. Lines of code intended for use in that environment will always be prefixed with three characters: three greater-than signs (>>>) or three periods (. . .). Lines with greater-than signs are the outermost block of code, while the period-prefixed lines are indented at least one level. The three initial characters are also followed by a space. These first four characters are not typed into the interactive interpreter directly; they simply mimic what the interpreter itself looks like by reproducing its output.

A line started with three periods but containing no other text indicates that you should simply press Enter on a blank line in the interpreter. This completes any open code blocks, bringing you back to the >>> prompt. Any lines that don’t begin with either >>> or . . . represent the output of the code or the result of the previous expression.

>>> import django
>>> django.get_version()
'1.5.1'

The first line of an interactive example will always begin with >>>; everything else is code that should be written in a file and executed as part of a running Django application. The surrounding text will indicate what file the code should be placed in and how it will execute.

Prerequisites

Pro Django is written for Django 1.5, which was released on February 26, 2013. That release or a more recent clone of the Django code repository is required for the code samples to work properly. Since Django in turn relies on Python, these examples also assume a working Python environment of version 2.7 or higher. Most of the code examples are written with Python 3.3 in mind, but there are capability notes available where older versions diverge from the examples shown.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset