您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

introduction.rst 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 to be constructed. 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. However, 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.
  12. Aims of project
  13. ---------------
  14. * To be a portable Django application that provides ecommerce functionality.
  15. * To comprise a set of loosely coupled apps that can be overridden in projects (interdependence is on interfaces only)
  16. * To be highly customisable so any part of the core can be customised.
  17. The central aim is to provide a solid core of an ecommerce project that can be
  18. extended and customised to suit the domain at hand. One way to acheive this is
  19. to have enormous models that have fields for every possible variation; however,
  20. this is unwieldy and ugly.
  21. A more elegant solution is to have minimal models where all the fields are meaningful
  22. within any ecommerce domain. In general, this means more work up front in
  23. terms of creating the right set of models but leads ultimately to a much
  24. cleaner and coherent system.
  25. Core design decisions
  26. ---------------------
  27. The central aim of django-oscar is to be a flexible app, that can be customised (rather than
  28. configured) to suit the domain at hand. This is acheived in several ways:
  29. * **All core models are abstract.** In each sub-app, there is an
  30. `abstract_models.py` file which
  31. defines abstract super-classes for every core model. There is also an
  32. accompanying `models.py` file which provides a vanilla concrete implementation
  33. of each model. The apps are structured this way so that any model can be
  34. subclassed and extended. You would do this by creating an app in your project
  35. with the same top-level app label as the one you want to modify (eg
  36. `myshop.product` to modify `oscar.product`). You can then create a models.py
  37. file which imports from the corresponding abstract models file but your
  38. concrete implementations can add new fields and methods. For example, in a
  39. clothes shop, you might want your core `product.Item` model to support fields
  40. for `Label`.
  41. * **Avoidance of the [Entity-Attribute-Value](http://en.wikipedia.org/wiki/Entity-attribute-value_model) pattern**.
  42. This technique of subclassing and extending
  43. models avoids an over-reliance on the using the EAV pattern which is commonly used to store data and meta-data about
  44. domain objects.
  45. * **Classes are loaded generically.** To enable sub-apps to be overridden, oscar classes are loading generically
  46. using a special `import_module` function. This looks at the `INSTALLED_APPS` tuple to determine the appropriate
  47. app to load a class from.
  48. * **All core views are class-based.** This enables any view to be subclassed and extended within your project.
  49. * **Any template can be overridden by a local version** This is a simple technique relying on the fact
  50. that the template loader can be configured to look in your project first for oscar templates.