This book presents the implementation of web-based e-commerce applications using Django, the powerful Python-based web framework. It emphasizes common Django coding patterns, writing reusable apps, and leveraging community resources and open-source tools.
Django and Python can be used to build everything from quick application prototypes in an afternoon, to full-blown production applications with long-term lifecycles.
Chapter 1, Django and E-commerce Development, introduces Django, provides a quick overview of its history, and evaluates it as an e-commerce platform. We also introduce the concept of Django applications versus "apps", how to code for reusability, and why Django's project layout allows us to write more powerful, flexible software. Finally, we will begin configuring the sample project built-upon throughout the book.
Chapter 2, Setting Up Shop in 30 Minutes, shows us how to create a very simple, but complete, e-commerce store in 30 minutes. This includes the creation of a product catalog and categorization system using Django models, using built-in generic views to expose our catalog to the Web, and attaching a simple Google Checkout integration.
Chapter 3, Handling Customers and Their Orders, deals with customer and order management, including the use of Django's auth module, registration and profile forms. We'll also build a simple order-taking system and connect it to our customer data. Finally, we demonstrate a quick and easy way of handling customer product reviews.
Chapter 4, Building Payment Processors, starts to extend the simple system built thus far by creating a "pluggable" payment processing system, and updating our Google Checkout support to take advantage of it. Finally, this chapter discusses the Django pattern of class-based views and how to use them with our payment processing framework.
Chapter 5, From Payment to Porch: An Order Pipeline, adds additional information to our order-taking system, including tracking status and shipping, plus automatic calculation of shipping and handling charges. We integrate these new features into a simple CRM tool that would allow staff to look-up order details and monitor status.
Chapter 6, Searching the Product Catalog, explores the options for adding search capabilities to our catalog, including use of Django with, Sphinx, Solr, Whoosh, Haystack, and Xapian search. We integrate several of these search engines into our project and present the Haystack community-project that allows generic integration of a variety of search-engine backends.
Chapter 7, Data and Report Generation, covers report generation and working with our application's data. This includes serializing and exposing data via a web API, generating RSS and Atom feeds, and the basics of Salesforce integration. We also use Python charting modules to automatically generate PDF-based reports.
Chapter 8, Creating Rich, Interactive UIs, provides an overview of JavaScript and AJAX integration with our Django project. We discuss how to expose our Django model data as JSON and write clean JavaScript to enhance our user interfaces. We finish by demonstrating a simple AJAX rating tool.
Chapter 9, Selling Digital Goods, presents digital goods and the various tools and APIs to sell them. Digital goods include products, like music or video media, which are sold and distributed electronically. We cover using Amazon S3 for storage with Django and integrating with the Amazon Flexible Payment Services, which offers an API for handling micropayments.
Chapter 10, Deployment and Maintenance Strategies, offers us a variety of pointers for configuring, deploying, and maintaining our Django applications. This includes setting up Apache with mod_wsgi
, automating a deployment process with fabric, handling virtual environments, and building distributable modules.
This book requires Django 1.0 or higher and assumes a basic working knowledge of the Django framework and novice Python programming skills.
This book is for anyone who is interested in learning more about application development with the Django framework. E-commerce applications contain a lot of general application design issues and make for a great example development project for anyone interested in Django applications generally.
We've assumed a fairly minimal amount of knowledge about the Django framework and Python language. But the book is geared at Django developers who have at least completed the Django tutorial and/or written some trivial apps.
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text are shown as follows: "To start with, create a new directory and place it on your PYTHONPATH
".
A block of code is set as follows:
class Catalog(models.Model): name = models.CharField(max_length=255 slug = models.SlugField(max_length=150) publisher = models.CharField(max_length=300) description = models.TextField() pub_date = models.DateTimeField(default=datetime.now)
Any command-line input or output is written as follows:
$ django-admin.py index—rebuild
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "This code defines a two-column table with headings Product Name and Product Description, and then renders the product inventory into each row in the table".
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <[email protected]>
, and mention the book title via the subject of your message.
If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail <[email protected]>
.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book on, see our author guide on www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
Note
Downloading the example code for the book
Visit https://www.packtpub.com//sites/default/files/downloads/7009_Code.zip to directly download the example code.
The downloadable files contain instructions on how to use them.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]>
with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
You can contact us at <[email protected]>
if you are having a problem with any aspect of the book, and we will do our best to address it.