shuup.core package



shuup.core.error_handling module

class shuup.core.error_handling.ErrorPageHandler[source]

Bases: object

A base class for error pages handling.

classmethod can_handle_error(request, error_status)[source]

Returns whether this object can handle the error :rtype: bool

classmethod handle_error(request, error_status)[source]

Returns a response for the given request and error status :rtype: django.http.HttpResponse


A factory of error views which tries to find a compatible error handler If not handler can do the job, use the Django’s default or a blank response


Install custom error handlers. Error handlers to be added are for errors 400, 403, 404, and 500.

shuup.core.excs module

exception shuup.core.excs.ImmutabilityError[source]

Bases: ValueError

exception shuup.core.excs.NoShippingAddressException[source]

Bases: Exception

exception shuup.core.excs.NoProductsToShipException[source]

Bases: Exception

exception shuup.core.excs.NoPaymentToCreateException[source]

Bases: Exception

exception shuup.core.excs.NoRefundToCreateException[source]

Bases: Exception

exception shuup.core.excs.RefundExceedsAmountException[source]

Bases: Exception

exception shuup.core.excs.RefundExceedsQuantityException[source]

Bases: Exception

exception shuup.core.excs.InvalidRefundAmountException[source]

Bases: Exception

exception shuup.core.excs.MissingSettingException[source]

Bases: Exception

exception shuup.core.excs.ProductNotOrderableProblem(message, title=None)[source]

Bases: shuup.utils.excs.Problem

exception shuup.core.excs.ProductNotVisibleProblem(message, title=None)[source]

Bases: shuup.utils.excs.Problem

exception shuup.core.excs.ImpossibleProductModeException(message, code=None)[source]

Bases: ValueError

shuup.core.middleware module

class shuup.core.middleware.ExceptionMiddleware[source]

Bases: object

process_exception(request, exception)[source]
class shuup.core.middleware.ShuupMiddleware[source]

Bases: object

Handle Shuup specific tasks for each request and response.

  • Sets the current shop according to the host name : shuup.core.models.Shop

    System Message: ERROR/3 (/home/docs/checkouts/ of shuup.core.middleware.ShuupMiddleware, line 5)

    Unexpected indentation.

    Currently active Shop.


shuup.core.settings module

shuup.core.settings.SHUUP_HOME_CURRENCY = 'EUR'

The home currency for the Shuup installation. All monetary values are implicitly in this currency unless somehow otherwise specified.

shuup.core.settings.SHUUP_ADDRESS_HOME_COUNTRY = None

The home country code (ISO 3166-1 alpha 2) for the Shuup installation. Among other things, addresses that would be printed with this country visible are printed with no country.

shuup.core.settings.SHUUP_ALLOW_ANONYMOUS_ORDERS = True

Whether or not anonymous orders (without a creator user) are allowed.

shuup.core.settings.SHUUP_ORDER_IDENTIFIER_METHOD = 'id'

Which method is used to calculate order identifiers (“order numbers”). May be either the string “id”, a callable or a spec string pointing to a callable that must return a string given an order.

shuup.core.settings.SHUUP_REFERENCE_NUMBER_METHOD = 'unique'

Which method is used by default to calculate order reference numbers.

May be a spec string pointing to a callable that must return a string given an Order, or one of the following built-in generators.

Unique reference number based on time and the order ID. The reference number has the Finnish bank reference check digit appended, making the reference number valid for Finnish bank transfers.
Ascending reference number. The length of the reference number will be SHUUP_REFERENCE_NUMBER_LENGTH + 1 (for the check digit described below). SHUUP_REFERENCE_NUMBER_PREFIX is prepended, if set. The reference number has the Finnish bank reference check digit appended, making the reference number valid for Finnish bank transfers.
As running, but with the shop ID prepended.
shuup.core.settings.SHUUP_REFERENCE_NUMBER_LENGTH = 17

The default length of reference numbers generated by certain reference number generators.

shuup.core.settings.SHUUP_REFERENCE_NUMBER_PREFIX = ''

An arbitrary (numeric) default prefix for certain reference number generators.

shuup.core.settings.SHUUP_PRICING_MODULE = 'customer_group_pricing'

The identifier of the pricing module to use for pricing products.

Determines how product prices are calculated. See shuup.core.pricing for details.

shuup.core.settings.SHUUP_DISCOUNT_MODULES = ['customer_group_discount', 'product_discounts']

List of identifiers of discount modules to use.

Each discount module may change the price of a product. See shuup.core.pricing.DiscountModule for details.

shuup.core.settings.SHUUP_ORDER_SOURCE_MODIFIER_MODULES = ['basket_campaigns', 'discounts_coupon_codes']

List of identifiers of order source modifier modules.

See shuup.core.order_creator.OrderSourceModifierModule for details.

shuup.core.settings.SHUUP_TAX_MODULE = 'default_tax'

The identifier of the tax module to use for determining taxes of products and order lines.

Determines taxing rules for products, shipping/payment methods and other order lines. See shuup.core.taxing for details.

shuup.core.settings.SHUUP_ENABLE_ATTRIBUTES = True

Whether product attributes are enabled. For installations not requiring attributes, disabling this may confer a small performance increase.

shuup.core.settings.SHUUP_ENABLE_MULTIPLE_SHOPS = False

Whether multiple shops are expected to be enabled in this installation. Enabling or disabling this flag does not make it (im)possible to set up multiple shops, but having it disabled may confer a small performance increase.

shuup.core.settings.SHUUP_ENABLE_MULTIPLE_SUPPLIERS = False

Whether multiple suppliers are enabled in this installation. Enabling this flag allows supplier creation from admin.

shuup.core.settings.SHUUP_MANAGE_CONTACTS_PER_SHOP = False

Indicates whether Shuup should restrict Contact access per Shop

This is useful when multi-shop is in use and the contact shouldn’t be visible by other shops.

The contact will be visible for shops in which user registered or placed an order.

shuup.core.settings.SHUUP_ORDER_LABELS = [('default', 'Default')]

A list of order labels (2-tuples of internal identifier / visible name).

Order labels serve as a simple taxonomy layer for easy “tagging” of orders even within a single Shop. For instance, an installation could define "default" and "internal" order labels, which are then usable in reports, admin filtering, etc.

shuup.core.settings.SHUUP_DEFAULT_ORDER_LABEL = 'default'

The order label (see SHUUP_ORDER_LABELS) to apply to orders by default. This should naturally be one of the keys in SHUUP_ORDER_LABELS.

shuup.core.settings.SHUUP_ORDER_KNOWN_PAYMENT_DATA_KEYS = []

A list of “known keys” within the Order.payment_data property bag.

The format of this setting is a list of 2-tuples of dict key / visible name, for example [("ssn", "Social Security Number")].

For installations where customizations may save some human-readable, possibly important information in payment_data, this setting may be used to make this data easily visible in the administration backend.


A list of “known keys” within the Order.shipping_data property bag.

The format of this setting is a list of 2-tuples of dict key / visible name, for example [("shipping_instruction", "Special Shipping Instructions")].

For installations where customizations may save some human-readable, possibly important information in shipping_data, this setting may be used to make this data easily visible in the administration backend.

shuup.core.settings.SHUUP_ORDER_KNOWN_EXTRA_DATA_KEYS = []

A list of “known keys” within the Order.extra_data property bag.

The format of this setting is a list of 2-tuples of dict key / visible name, for example [("wrapping_color", "Wrapping Paper Color")].

For installations where customizations may save some human-readable, possibly important information in extra_data, this setting may be used to make this data easily visible in the administration backend.

shuup.core.settings.SHUUP_TELEMETRY_ENABLED = True

A flag to enable/disable the telemetry system

shuup.core.settings.SHUUP_TELEMETRY_HOST_URL = ''

The host URL for Shuup’s telemetry (statistics) system

shuup.core.settings.SHUUP_TELEMETRY_URL = ''

The submission URL for Shuup’s telemetry (statistics) system

shuup.core.settings.SHUUP_SUPPORT_ID_URL = ''

The URL to fetch the Shuup installation support id

shuup.core.settings.SHUUP_DEFAULT_CACHE_DURATION = 1800

Default cache duration for various caches in seconds

shuup.core.settings.SHUUP_CACHE_DURATIONS = {}

Overrides for default cache durations by key namespace. These override possible defaults in shuup.core.cache.impl.DEFAULT_CACHE_DURATIONS.


Whether taxes should be calculated automatically in TaxModule

shuup.core.settings.SHUUP_ADDRESS_FORMATTER_SPEC = 'shuup.core.utils.formatters:DefaultAddressFormatter'

Spec which defines an address formatter used to format output string of an Address model instances

shuup.core.settings.SHUUP_ADDRESS_MODEL_FORM = 'shuup.core.utils.forms.MutableAddressForm'

Spec which defines an default address model form

shuup.core.settings.SHUUP_ADDRESS_FIELD_PROPERTIES = {}

A dictionary defining properties to override the default field properties of the checkout address form and also the Address API.

System Message: ERROR/3 (/home/docs/checkouts/ of shuup.core.settings.SHUUP_ADDRESS_FIELD_PROPERTIES, line 3)

Unexpected indentation.
Should map the field name (as a string) to a dictionary containing the overriding Django form field properties, as in the following

System Message: WARNING/2 (/home/docs/checkouts/ of shuup.core.settings.SHUUP_ADDRESS_FIELD_PROPERTIES, line 5)

Block quote ends without a blank line; unexpected unindent.

example which makes the postal code a required field:

“postal_code”: {“required”: True}

System Message: WARNING/2 (/home/docs/checkouts/ of shuup.core.settings.SHUUP_ADDRESS_FIELD_PROPERTIES, line 9)

Definition list ends without a blank line; unexpected unindent.


Some of the Django form field properties will not affect Address API. The valid set of properties are those defined by the Serializer fields core arguments like read_only, required, allow_null, etc. See the Django Rest Framework documentation for more properties.

It should be noted, however, that overriding some settings (such as making a required field non-required) could create other validation issues.

shuup.core.settings.SHUUP_MAX_DAYS_IN_TELEMETRY = 180

Indicates maximum days for daily data included to one telemetry request


Spec which defines if shop product categories will be automatically populated on save or when the shop_product categories change.

Example A: shop_product.categories = [] shop_product.primary_category = “A” => “A” will be added to categories

Example B: shop_product.primary_category = None shop_product.categories = [“A”, “B”] => “A” will be made the shop_product.primary_category

shuup.core.settings.SHUUP_ERROR_PAGE_HANDLERS_SPEC = []

Spec which defines a list of handlers of page errors overwriting Django’s default error handlers configured in (if some).

Shuup will iterate over all handlers in order to determinate if some can handle the error. In case of no handler can do the job, a blank response will be returned.

A handler must be a subclass of shuup.core.error_handling.ErrorPageHandler.

If no handler is set (blank), Shuup will use default Django’s handlers.

shuup.core.settings.SHUUP_SHOP_PRODUCT_SUPPLIERS_STRATEGY = 'shuup.core.suppliers.FirstSupplierStrategy'

Spec which defines shop product supplier strategy Used to determine how the supplier is selected for source line and orderability checks.

This spec defines class which should implement get_supplier-method for which the current shop product with customer, quantity and shipping address is passed as kwargs.

shuup.core.settings.SHUUP_REQUEST_SHOP_PROVIDER_SPEC = 'shuup.core.shop_provider.DefaultShopProvider'

Spec which provides the current shop for a given request and set of parameters.

shuup.core.settings_provider module

class shuup.core.settings_provider.BaseSettingsProvider[source]

Bases: object

provided_settings = []
class shuup.core.settings_provider.ShuupSettings[source]

Bases: object

classmethod get_setting(setting_key)[source]

shuup.core.shop_provider module

class shuup.core.shop_provider.DefaultShopProvider[source]

Bases: object

classmethod get_shop(request, **kwargs)[source]
shuup.core.shop_provider.get_shop(request, **kwargs)[source]

shuup.core.signal_handers module

shuup.core.signal_handers.handle_post_save_bump_all_prices_caches(sender, instance, **kwargs)[source]
shuup.core.signal_handers.handle_product_post_save(sender, instance, **kwargs)[source]
shuup.core.signal_handers.handle_shop_product_post_save(sender, instance, **kwargs)[source]
shuup.core.signal_handers.handle_contact_post_save(sender, instance, **kwargs)[source]

shuup.core.signals module

shuup.core.signals.stocks_updated = <django.dispatch.dispatcher.Signal object>

Send from supplier module after the stocks updated have been triggered after order, shipment and shop product change.

For example:
You can attach signal receiver for this to change product visibility after it has become unorderable.

shuup.core.telemetry module

shuup.core.telemetry.safe_json(data_dict, indent=None)[source]

Get the unique installation ID for this Shuup instance.

If one doesn’t exist, it’s generated and saved at this point.

Returns:Installation key string
Return type:str

Return True if the telemetry module is within the 24-hours-from-installation grace period where no stats are sent. This is to “safely” allow opting out of telemetry without leaving a trace.

Returns:Graceness flag.
Return type:bool

Set whether this installation is opted-out from telemetry submissions.

Parameters:flag (bool) – Opt-out flag. True for opt-out, false for opt-in (default)
Returns:New flag state
Return type:bool

Save a blob of data as the latest telemetry submission.

Naturally updates the latest submission time.

Parameters:data (dict) – A blob of data.
shuup.core.telemetry.daterange(start_date, end_date)[source]
shuup.core.telemetry.get_telemetry_data(request, indent=None)[source]

Get the telemetry data that would be sent.

Parameters:request (django.http.HttpRequest|None) – HTTP request. Optional.
Returns:Data blob.
Return type:str
exception shuup.core.telemetry.TelemetryNotSent(message, code)[source]

Bases: Exception

shuup.core.telemetry.try_send_telemetry(request=None, max_age_hours=24, raise_on_error=False)[source]

Send telemetry information (unless opted-out, in grace period or disabled).

Telemetry will be always sent if there is no prior sending information.

  • request (django.http.HttpRequest|None) – HTTP request. Optional.
  • max_age_hours (int|None) – How many hours must have passed since the last submission to be able to resend. If None, not checked.
  • raise_on_error (bool) – Raise exceptions when telemetry is not sent instead of quietly returning False.

Sent data (possibly with response information) or False if not sent.

Return type:


Module contents

class shuup.core.ShuupCoreAppConfig(*args, **kwargs)[source]

Bases: shuup.apps.AppConfig

name = 'shuup.core'
verbose_name = 'Shuup Core'
label = 'shuup'
required_installed_apps = ('django.contrib.auth', 'django.contrib.contenttypes', 'easy_thumbnails', 'filer')
provides = {'api_populator': ['shuup.core.api:populate_core_api'], 'pricing_module': ['shuup.core.pricing.default_pricing:DefaultPricingModule'], 'order_source_validator': ['shuup.core.order_creator:OrderSourceMinTotalValidator', 'shuup.core.order_creator:OrderSourceMethodsUnavailabilityReasonsValidator', 'shuup.core.order_creator:OrderSourceSupplierValidator']}