<commit_before>.. _tutorial/intro:

========
Tutorial
========

This tutorial is aimed at people new to django SHOP but already familiar with Django. If you aren't
yet, reading their excellent `Django Tutorial`_ is highly recommended.

Since **django-SHOP** relies on many features offered by **django-CMS** and **Django REST Framework**,
you should familiarize yourself with these apps.


Introduction
============

**Django-SHOP** is an e-commerce framework rather than a turn-key solution. Therefore beginners
are strongly recommended to start with one of the provided examples. These demos are what we
describe as the "*merchant implementation*". Here merchants provide their product models, templates
and everything else, which is required to get their customized shop up and running. This approach
allows us to implement every desired extra feature, without having to implement everything from
scratch.

Currently **django-SHOP** is shipped with 6 merchant demo implementations:

* :ref:`tutorial/product-model-commodity` and :ref:`tutorial/product-model-i18n_commodity`
* :ref:`tutorial/product-model-smartcard` and :ref:`tutorial/product-model-i18n_smartcard`
* :ref:`tutorial/product-model-polymorphic` and :ref:`tutorial/product-model-i18n_polymorphic`

You may install them manually and populate their content yourself. The recommended way however,
is to install them manually, and :ref:`tutorial/populate-database-fixtures`.

If you have a Docker runtime on your workstation, an even quicker approach is to
:ref:`tutorial/quickstart`.


.. _tutorial/prepare-installation:

Prepare the Installation
========================

To run the examples shown in this tutorial, you must install **django-SHOP** from GitHub, since
the pip-installable from PyPI only contains the framework, but not the files required for the demos.
Before proceeding, please make sure virtualenv_ is installed on your system, otherwise you would
pollute your Python site-packages folder.

Because we are using the current Github master for this tutorial, you must also
use the documentation for the current Github master. If you are reading this
document on Read The Docs, please look for the version selector (usually at the
bottom of the screen) and select "latest".

Also ensure that these packages are installed using the favorite package manager of your operating
system:

* Python 2.7, 3.5 or 3.6 (recommended)
* Redis: http://redis.io/
* SQLite: https://www.sqlite.org/
* Node Package Manager: https://www.npmjs.com/
* Optionally Elasticsearch version 1.7.5 (not later)

.. code-block:: shell

	$ mkdir Tutorial; cd Tutorial
	$ virtualenv -p $(which python3) shoptutorial
	$ source shoptutorial/bin/activate
	(shoptutorial)$ pip install -U pip setuptools
	(shoptutorial)$ git clone --depth 1 https://github.com/awesto/django-shop
	(shoptutorial)$ cd django-shop
	(shoptutorial)$ pip install 'Django<2.0' 'django-select2<6.1' 'django-angular<2.1'
	(shoptutorial)$ pip install -r requirements/common.txt
	(shoptutorial)$ pip install --no-deps -e .
	(shoptutorial)$ cd example
	(shoptutorial)$ npm install

These statements will setup an environment that runs one of the demo shops out of the box.

.. note:: We recommend that you use Python 3, but if you stuck with Python-2.7, please note that
	you have to additionally invoke ``pip install enum34 funcsigs``.


.. _tutorial/create-demo-database:

Create a database for the demo
------------------------------

Finally we must create a database to run our example project:

.. code-block:: shell

	(shoptutorial)$ cd django-shop/example
	(shoptutorial)$ export DJANGO_SHOP_TUTORIAL=commodity DJANGO_DEBUG=1
	(shoptutorial)$ ./manage.py migrate
	(shoptutorial)$ ./manage.py createsuperuser
	Email address: <EMAIL>
	Username: admin
	Password:<commit_msg>Update intro.rst<commit_after>.. _tutorial/intro:

========
Tutorial
========

This tutorial is aimed at people new to django SHOP but already familiar with Django. If you aren't
yet, reading their excellent `Django Tutorial`_ is highly recommended.

Since **django-SHOP** relies on many features offered by **django-CMS** and **Django REST Framework**,
you should familiarize yourself with these apps.


Introduction
============

**Django-SHOP** is an e-commerce framework rather than a turn-key solution. Therefore beginners
are strongly recommended to start with one of the provided examples. These demos are what we
describe as the "*merchant implementation*". Here merchants provide their product models, templates
and everything else, which is required to get their customized shop up and running. This approach
allows us to implement every desired extra feature, without having to implement everything from
scratch.

Currently **django-SHOP** is shipped with 6 merchant demo implementations:

* :ref:`tutorial/product-model-commodity` and :ref:`tutorial/product-model-i18n_commodity`
* :ref:`tutorial/product-model-smartcard` and :ref:`tutorial/product-model-i18n_smartcard`
* :ref:`tutorial/product-model-polymorphic` and :ref:`tutorial/product-model-i18n_polymorphic`

You may install them manually and populate their content yourself. The recommended way however,
is to install them manually, and :ref:`tutorial/populate-database-fixtures`.

If you have a Docker runtime on your workstation, an even quicker approach is to
:ref:`tutorial/quickstart`.


.. _tutorial/prepare-installation:

Prepare the Installation
========================

To run the examples shown in this tutorial, you must install **django-SHOP** from GitHub, since
the pip-installable from PyPI only contains the framework, but not the files required for the demos.
Before proceeding, please make sure virtualenv_ is installed on your system, otherwise you would
pollute your Python site-packages folder.

Because we are using the current Github master for this tutorial, you must also
use the documentation for the current Github master. If you are reading this
document on Read The Docs, please look for the version selector (usually at the
bottom of the screen) and select "latest".

Also ensure that these packages are installed using the favorite package manager of your operating
system:

* Python 2.7, 3.5 or 3.6 (recommended)
* Redis: http://redis.io/
* SQLite: https://www.sqlite.org/
* Node Package Manager: https://www.npmjs.com/
* Optionally Elasticsearch version 1.7.5 (not later)

.. code-block:: shell

	$ mkdir Tutorial; cd Tutorial
	$ virtualenv -p $(which python3) shoptutorial
	$ source shoptutorial/bin/activate
	(shoptutorial)$ pip install -U pip setuptools
	(shoptutorial)$ git clone --depth 1 https://github.com/awesto/django-shop
	(shoptutorial)$ cd django-shop
	(shoptutorial)$ pip install 'Django<2.0' 'django-select2<6.1' 'django-angular<2.1'
	(shoptutorial)$ pip install -r requirements/common.txt
	(shoptutorial)$ pip install -r requirements.txt
	(shoptutorial)$ pip install --no-deps -e .
	(shoptutorial)$ cd example
	(shoptutorial)$ npm install

These statements will setup an environment that runs one of the demo shops out of the box.

.. note:: We recommend that you use Python 3, but if you stuck with Python-2.7, please note that
	you have to additionally invoke ``pip install enum34 funcsigs``.


.. _tutorial/create-demo-database:

Create a database for the demo
------------------------------

Finally we must create a database to run our example project:

.. code-block:: shell

	(shoptutorial)$ cd django-shop/example
	(shoptutorial)$ export DJANGO_SHOP_TUTORIAL=commodity DJANGO_DEBUG=1
	(shoptutorial)$ ./manage.py migrate
	(shoptutorial)$ ./manage.py createsuperuser
	Email address: <EMAIL>
	Username: admin
	Password:
{'fraction_non_alphanumeric': 0.10214772132006286, 'fraction_numerical': 0.008119434258774228, 'mean_word_length': 4.6780669144981415, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 6, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2063201', 'n_tokens_mistral': 2232, 'n_tokens_neox': 2081, 'n_words': 899}