ebook img

Beginning Django E-Commerce - McGaw - Apress PDF

409 Pages·2011·5.07 MB·English
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Beginning Django E-Commerce - McGaw - Apress

Cyan yelloW MaGenTa BlaCk Books for professionals By professionals® The eXperT’s VoiCe® in WeB DeVelopMenT Companion eBook Available Beginning Django E-Commerce Beginning Dear Reader, Beginning D Django is a web framework that allows developers to build clean and elegant web sites. In this book we take an in-depth and detailed look at using Django to build a fully functional e-commerce web site. Whether you’re a seasoned web j programmer looking to try Django or completely new to the realm of dynamic a Django web development, this book will give you the theoretical groundwork and prac- n tical guidance you need to develop your ideas into a working site. Best of all, Django and Python are open source, so they’re free for anyone to use. g As a developer, I have always enjoyed learning new things by example. For this reason, we will build a single shopping cart site over the course of this book. o Chapter by chapter, we’ll add new features and functionality to the site, all the while discussing the theory behind the code we’re writing. In the end, our site will have a product catalog, shopping cart, checkout functionality, payment E-Commerce E gateway integration, customer accounts, order administration, product search, cross-selling, automated test cases, and secure credit card storage. You’ll see - how all of these individual pieces fit together to create a search engine-friendly site, learn Django best practices in the process, and come away with a code C base that you can re-use in your other projects. Because Django was created using the Python programming language, you o get the benefit of several solutions to existing problems that have been put forth by the heavily active Python community on the web. As a language, Python is m very powerful, and because of this, there is almost no limit to the kinds of sites you can build, the complexity of which is all made simple using Django. After learning the concepts covered in this book, you’ll be well on your way to devel- m oping your own fully featured, production-ready Django web sites. Have fun developing along with this book! Learn how to build powerful e-commerce sites e Jim McGaw using the Django web framework and the Python r programming language Companion eBook THE APRESS ROADMAP c e Beginning Django Definitive Guide to Django, Pro Django E-Commerce 2nd edition See last page for details on $10 eBook version Practical Django Projects, 2nd edition SOURCE CODE ONLINE M Jim McGaw www.apress.com (cid:41)(cid:51)(cid:34)(cid:46)(cid:0)(cid:25)(cid:23)(cid:24)(cid:13)(cid:17)(cid:13)(cid:20)(cid:19)(cid:16)(cid:18)(cid:13)(cid:18)(cid:21)(cid:19)(cid:21)(cid:13)(cid:21) c (cid:21)(cid:20)(cid:20)(cid:25)(cid:25) G a w US $44.99 Shelve in Web Development / General User level: (cid:25) (cid:23)(cid:24)(cid:17)(cid:20)(cid:19)(cid:16) (cid:18)(cid:18)(cid:21)(cid:19)(cid:21)(cid:21) Beginner to Intermediate this print for content only—size & color not accurate trim = 7.5" x 9.25" spine = 0.75" 408 page count Beginning Django E-Commerce ■ ■ ■ JIM MCGAW Beginning Django E-Commerce Copyright © 2009 by Jim McGaw All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-4302-2535-5 ISBN-13 (electronic): 978-1-4302-2536-2 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Lead Editor: Duncan Parkes Development Editor: Douglas Pundick Technical Reviewer: George Vilches Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Tony Campbell, Gary Cornell, Jonathan Gennick, Michelle Lowman, Matthew Moodie, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Coordinating Editor: Jim Markham Copy Editor: Ralph Moore Compositor: Mary Sudul Indexer: Carol Burbo Artist: April Milne Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail [email protected], or visit http://www.springeronline.com. For information on translations, please contact Apress directly at 2855 Telegraph Avenue, Suite 600, Berkeley, CA 94705. Phone 510-549-5930, fax 510-549-5939, e-mail [email protected], or visit http://www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales—eBook Licensing web page at http://www.apress.com/info/bulksales. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.com. You will need to answer questions pertaining to this book in order to successfully download the code. This book is dedicated to my parents. —Jim McGaw ■ CONTENTS Contents at a Glance ■ About the Author....................................................................................................xi ■ About the Technical Reviewer...............................................................................xii ■ Acknowledgments................................................................................................xiii ■ Introduction..........................................................................................................xiv ■ Chapter 1: Best Laid Plans.......................................................................................1 ■ Chapter 2: Creating a Django Site..........................................................................17 ■ Chapter 3: Models for Sale....................................................................................39 ■ Chapter 4: The Shopping Cart................................................................................79 ■ Chapter 5: Site Checkout & Orders......................................................................109 ■ Chapter 6: Creating User Accounts......................................................................153 ■ Chapter 7: Product Images..................................................................................173 ■ Chapter 8: Implementing Product Search...........................................................179 ■ Chapter 9: Intelligent Cross-Selling.....................................................................193 ■ Chapter 10: Adding in Ajax..................................................................................205 ■ Chapter 11: Search Engine Optimization.............................................................231 ■ Chapter 12: Web Security Overview....................................................................255 ■ Chapter 13: Improving Performance...................................................................279 ■ Chapter 14: Django Testing.................................................................................299 ■ Chapter 15: Deployment......................................................................................323 ■ Chapter 16: Django on Google App Engine..........................................................341 ■ Index....................................................................................................................365 v vi ■ CONTENTS Contents ■ About the Author..................................................................................................xvi ■ About the Technical Reviewer.............................................................................xvii ■ Acknowledgments..............................................................................................xviii ■ Introduction..........................................................................................................xix ■ Chapter 1: Best Laid Plans.......................................................................................1 Selling Stuff Online........................................................................................................................2 Why Django?..................................................................................................................................4 Straying From the Django Philosophy.......................................................................................5 A Quick Word on the Software..................................................................................................5 A Note on Version Control..........................................................................................................6 Firefox.......................................................................................................................................6 Installing the Software...................................................................................................................7 Installing Python........................................................................................................................7 Installing Django........................................................................................................................8 Installing MySQL........................................................................................................................9 Installing Eclipse and the PyDev Extensions.............................................................................9 Things to Consider Before You Start..............................................................................................9 Security...................................................................................................................................10 Accessibility............................................................................................................................10 PCI Compliance........................................................................................................................11 Search Engine Optimization....................................................................................................11 Deployment.............................................................................................................................12 Business Requirements...............................................................................................................12 Accounting & Auditing.............................................................................................................12 Supply Chain Management......................................................................................................13 Marketing Decisions................................................................................................................14 Summary......................................................................................................................................16 vii ■ CONTENTS ■ Chapter 2: Creating a Django Site..........................................................................17 A Django-istic Welcome...............................................................................................................17 Creating the Project.................................................................................................................17 What Django Creates...............................................................................................................18 Creating the MySQL Database.....................................................................................................19 Dealing with Django Exceptions...................................................................................................22 Template & View Basics...............................................................................................................23 Advanced Templates with Inheritance.........................................................................................25 Greater Ease with render_to_response().....................................................................................28 Adding in the CSS........................................................................................................................29 Location, Location, Location........................................................................................................34 A Site Navigation Include.............................................................................................................35 A Word (or Two) About URLs........................................................................................................37 Summary......................................................................................................................................38 ■ Chapter 3: Models for Sale....................................................................................39 Databases 101.............................................................................................................................40 An Introduction To SQL............................................................................................................40 What Makes a Relational Database.........................................................................................42 What Django Gives You – The ORM..............................................................................................44 Creating the Catalog App.............................................................................................................45 Creating the Django Models.........................................................................................................46 Model Field Data Types...........................................................................................................48 Creating the Category Model...................................................................................................50 Creating the Product Model.....................................................................................................54 The Django Admin Interface.........................................................................................................56 Product and Category Admins.................................................................................................57 A Note on Model Validation.....................................................................................................59 Syncing Up the Models............................................................................................................60 Playing with Model Structure and Data...................................................................................64 Templates, URLs, and Views........................................................................................................65 Configuring Page Titles and Meta Tags...................................................................................66 Coding Up the Catalog Views...................................................................................................68 Creating the Template Files.....................................................................................................69 A Category Link List.................................................................................................................73 viii

Description:
For information on translations, please contact Apress directly at 2855 Telegraph Avenue, Suite 600, Berkeley, CA. 94705. Phone the file system that contains application code, such as Default.aspx or index.php. VALUES ('Ruby Axe Guitar', 'Great guitar!', 299.99, 'Electric Guitars');.
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.