Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

getting_started.rst 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. ============================
  2. Start building your own shop
  3. ============================
  4. For simplicity, let's assume you're building a new e-commerce project from
  5. scratch and have decided to use Oscar. Let's call this shop 'frobshop'
  6. .. tip::
  7. You can always review the set-up of the `Sandbox site`_ in case you have
  8. trouble following the below instructions.
  9. .. _`Sandbox site`: https://github.com/tangentlabs/django-oscar/tree/releases/0.2/sandbox
  10. Install by hand
  11. ===============
  12. Install oscar (which will install Django as a dependency), then create the
  13. project::
  14. pip install django-oscar
  15. django-admin.py startproject frobshop
  16. This will create a folder ``frobshop`` for your project.
  17. Settings
  18. --------
  19. Now edit your settings file ``frobshop.frobshop.settings.py`` to specify a
  20. database (we use sqlite for simplicity)::
  21. DATABASES = {
  22. 'default': {
  23. 'ENGINE': 'django.db.backends.sqlite3',
  24. 'NAME': 'db.sqlite3',
  25. 'USER': '',
  26. 'PASSWORD': '',
  27. 'HOST': '',
  28. 'PORT': '',
  29. }
  30. }
  31. then add ``oscar.apps.basket.middleware.BasketMiddleware`` to ``MIDDLEWARE_CLASSES``, and
  32. set ``TEMPLATE_CONTEXT_PROCESSORS`` to::
  33. TEMPLATE_CONTEXT_PROCESSORS = (
  34. "django.contrib.auth.context_processors.auth",
  35. "django.core.context_processors.request",
  36. "django.core.context_processors.debug",
  37. "django.core.context_processors.i18n",
  38. "django.core.context_processors.media",
  39. "django.core.context_processors.static",
  40. "django.contrib.messages.context_processors.messages",
  41. 'oscar.apps.search.context_processors.search_form',
  42. 'oscar.apps.promotions.context_processors.promotions',
  43. 'oscar.apps.checkout.context_processors.checkout',
  44. 'oscar.core.context_processors.metadata',
  45. )
  46. Next, modify ``INSTALLED_APPS`` to be a list, add ``South`` and append Oscar's core apps::
  47. from oscar import get_core_apps
  48. INSTALLED_APPS = [
  49. 'django.contrib.auth',
  50. ...
  51. 'south',
  52. ] + get_core_apps()
  53. and set your auth backends to::
  54. AUTHENTICATION_BACKENDS = (
  55. 'oscar.apps.customer.auth_backends.Emailbackend',
  56. 'django.contrib.auth.backends.ModelBackend',
  57. )
  58. to allow customers to sign in using an email address rather than a username.
  59. Oscar currently uses Haystack for search so you need to specify::
  60. HAYSTACK_SITECONF = 'oscar.search_sites'
  61. HAYSTACK_SEARCH_ENGINE = 'dummy'
  62. The last addition to the settings file is to import all of Oscar's default settings::
  63. from oscar.defaults import *
  64. URLs
  65. ----
  66. Alter your ``frobshop/urls.py`` to include Oscar's URLs::
  67. from django.conf.urls import patterns, include, url
  68. from oscar.app import shop
  69. urlpatterns = ('',
  70. (r'', include(shop.urls))
  71. )
  72. Database
  73. --------
  74. Then create the database and the shop should be browsable::
  75. python manage.py syncdb --noinput
  76. python manage.py migrate
  77. You should now have a running Oscar install that you can browse.
  78. Install using Tangent's boilerplate django project
  79. ==================================================
  80. The easiest way to get started is to use Tangent's `template django project`_
  81. although it is tailored to an Agency structure which may not suit everyone.
  82. .. _`template django project`: https://github.com/tangentlabs/tangent-django-boilerplate
  83. Set up a virtualenv, and create a new project using the ``startproject``
  84. management command::
  85. mkvirtualenv frobshop
  86. pip install Django
  87. django-admin.py startproject frobshop \
  88. --template=https://github.com/tangentlabs/tangent-django-boilerplate/zipball/master
  89. This will create a folder ``frobshop`` which is an entire templated project that
  90. follows Tangent's conventions. The structure is::
  91. frobshop/
  92. docs/
  93. www/
  94. conf/
  95. deploy/
  96. public/
  97. static/
  98. templates/
  99. manage.py
  100. settings.py
  101. settings_test.py
  102. urls.py
  103. urls_oscar.py
  104. README.rst
  105. fabconfig.py
  106. fabfile.py
  107. deploy-to-test.sh
  108. deploy-to-stage.sh
  109. deploy-to-prod.sh
  110. Replace a few files with Oscar-specific versions::
  111. mv frobshop/www/urls{_oscar,}.py
  112. mv frobshop/www/deploy/requirements{_oscar,}.py
  113. mv frobshop/www/conf/default{_oscar,}.py
  114. Install dependencies::
  115. cd frobshop/www
  116. pip install -r deploy/requirements.txt
  117. Create database::
  118. python manage.py syncdb --noinput
  119. python manage.py migrate
  120. And that should be it.
  121. Next steps
  122. ==========
  123. The next step is to implement the business logic of your domain on top of
  124. Oscar.