Models

Why no product models?

There is no models production ready models bundled with this application because in our humble experience, the nature of a what constitutes a products varies wildly from one project to the next.

The goal of basky is to be lightweight and robust, so bundling complex ‘’and the kitchen sink’’ style product models is not inline with our aims for the application.

If however, you’re looking for a starting point you can find some very contrived examples in the test project.

Defining Your Own Product Models

basky doesn’t use the registry pattern, because it doesn’t care what you add into the basket. The only requirement is that the instance you add into the basket have a:

  • Property called name - String: used to make the basketitem description
  • Property called total - Decimal: formatted to two decimals places.

This is the only requirement. Nice and easy lemon squeezy.

Basket

Basket.add(self, item, **kwargs)

Accepts the following arguments

  • quantity - Integer: defaults to 1. Is the quantity of items to add to the basket.
  • price - Decimal: defaults to None. Overrides the price of the item
  • description - String: defaults to None. Overrides the name of the item
  • silent - Boolean: defaults to False. If True the pre_add_to_basket & post_add_to_basket signals will not be sent.
  • locked - Boolean: defaults to False. If True then the basket item will not be editable by user, so they won’t be able to remove it or update the quantity
  • append - Boolean: defaults to True. If True then the quantity will be added onto the current quantity. If False it will replace the current quantity.

Basket.remove(self, basketitem, **kwargs)

  • basketitem - BasketItem: The basket item that you want to remove from the basket.
  • silent - Boolean: defaults to False. If True the pre_add_to_basket & post_add_to_basket signals will not be sent.