You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

introduction.rst 3.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. Introduction
  2. ============
  3. Named after Oscar Peterson (http://en.wikipedia.org/wiki/Oscar_Peterson),
  4. django-oscar is a flexible ecommerce platform, designed to build domain-driven
  5. ecommerce sites. It is not supposed to be a framework that can
  6. be downloaded and fully set up by simply adjusting a configuration file: there
  7. will always be some developer work required to make sure the models match those
  8. from your domain - this is the nature of domain modelling.
  9. That said, a small amount of work up front in determine the right models for your
  10. shop can really pay off in terms of building a high-quality application that
  11. is a pleasure to work with and maintain. It's better to extend core models with fields
  12. relevant to your domain that attempting to write code so "generic" that is can handle
  13. any situation. This generally leads to a confusing mess.
  14. Aims of project
  15. ---------------
  16. * To be a portable Django application that provides ecommerce functionality.
  17. * To comprise a set of loosely coupled apps that can be overridden in;
  18. projects (interdependence is on interfaces only);
  19. * To be highly customisable so any part of the core can be customised.
  20. The central aim is to provide a solid core of an ecommerce project that can be
  21. extended and customised to suit the domain at hand. One way to acheive this is
  22. to have enormous models that have fields for every possible variation; however,
  23. this is unwieldy and ugly.
  24. A more elegant solution is to have minimal models where all the fields are meaningful
  25. within any ecommerce domain. In general, this means more work up front in
  26. terms of creating the right set of models but leads ultimately to a much
  27. cleaner and coherent system.
  28. Core design decisions
  29. ---------------------
  30. The central aim of django-oscar is to be a flexible app, that can be customised (rather than
  31. configured) to suit the domain at hand. This is acheived in several ways:
  32. * **All core models are abstract.** In each sub-app, there is an
  33. `abstract_models.py` file which
  34. defines abstract super-classes for every core model. There is also an
  35. accompanying `models.py` file which provides a vanilla concrete implementation
  36. of each model. The apps are structured this way so that any model can be
  37. subclassed and extended. You would do this by creating an app in your project
  38. with the same top-level app label as the one you want to modify (eg
  39. `myshop.product` to modify `oscar.product`). You can then create a models.py
  40. file which imports from the corresponding abstract models file but your
  41. concrete implementations can add new fields and methods. For example, in a
  42. clothes shop, you might want your core `product.Item` model to support fields
  43. for `Label`.
  44. * **Avoidance of the [Entity-Attribute-Value](http://en.wikipedia.org/wiki/Entity-attribute-value_model) pattern**.
  45. This technique of subclassing and extending models avoids an over-reliance
  46. on the using the EAV pattern which is commonly used to store data and
  47. meta-data about domain objects.
  48. * **Classes are loaded generically.** To enable sub-apps to be overridden,
  49. oscar classes are loading generically using a special `import_module`
  50. function. This looks at the `INSTALLED_APPS` tuple to determine the
  51. appropriate app to load a class from.
  52. * **All core views are class-based.** This enables any view to be subclassed and extended within your project.
  53. * **Any template can be overridden by a local version** This is a simple technique relying on the fact
  54. that the template loader can be configured to look in your project first for oscar templates.