Book Image

Django 1.2 E-commerce

By : Jesse Legg
Book Image

Django 1.2 E-commerce

By: Jesse Legg

Overview of this book

<p>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 provides an excellent basis to build e-commerce websites because it can be deployed fast and it responds quickly to changes due to its ability to handle content problems. Django with its proven strengths is all you need to build powerful e-commerce applications with a competitive edge. <br /><br />This book explores how the Django web framework and its related technologies can power the next leap forward for e-commerce and business on the Web. It shows you how to build real-world applications using this rapid and powerful development tool.<br /><br />The book will enable you to build a high quality e-commerce site quickly and start making money. It starts with the ambitious task of using Django to build a functional e-commerce store in less than 30 minutes, and then proceeds to enhance this design through the rest of the book. The book covers the basics of an e-commerce platform like product catalogs, shopping carts, and payment processing. By the end of the book, you will be able to enhance the application by adding a fully-functional search engine, generating PDF-based reports, adding interactivity to the user-interface, selling digital goods with micropayments, and managing deployment and maintenance tasks.</p>
Table of Contents (16 chapters)
Django 1.2 e-commerce
Credits
About the Author
About the Reviewers
Preface
Index

Reusable apps


Reusability is software engineering's Holy Grail. Unfortunately, over time it has often proven difficult to attain. It's almost impossible to build for reuse on the first try and other times it's just not practical. But it's still an important goal that often does work and leads to many efficiency gains.

In frameworks like Django that utilize an ORM to interact with and store information in a database, reusability faces additional challenges. The object-oriented programming model that is typically the heart of reusable code does not always translate into a relational database. Django's ORM does its best to accommodate this by offering a limited form of inheritance, for example, but it still has many challenges.

Another tendency is to build Django models that store data for overly specific problems. In Chapter 2, we will begin writing models for a product database. It would be very easy to apply model inheritance in an attempt to solve specific problems. For example, we may be tempted to extend a product model into a subclass specific for food: FoodProduct. We then may try and build a subclass specifically for noodles: NoodleProduct. Using inheritance this way often makes sense in other software projects, but when Django maps these models to the database, it can become a mess of entangled relationships and primary keys.

To avoid these issues with inheritance, some Django developers employ various model hacks. This includes things such as pickling attribute data into a text field or otherwise encoding extra attributes into a single field. These are often clever and sometimes very effective solutions, but they can also lead to bad designs and problems later on.

The best advice seems to be to keep things simple. Limit what your app does and the dependencies it needs to serve its core duty. Don't be afraid of developing a large app library.