Wishlists

The wishlists app allows signed-in users to create one or more wishlists. A user can add a product to their wishlist from the product detail page and manage their lists in the account section.

A wishlist can be private, public or shared. Private wishlist can only be seen by the owner of the wishlist, where public wishlists can be seen by anyone with the link. Shared wishlists have extra configuration, the owner of the wishlist can give access to multiple email addresses. The shared addresses will need an account on the webshop and need to be logged in in order to access the wishlist.

The wishlists app is wired up as a subapp of Customer for the customer wish list related views.

Abstract models

class oscar.apps.wishlists.abstract_models.AbstractLine(*args, **kwargs)[source]

One entry in a wish list. Similar to order lines or basket lines.

title

Store the title in case product gets deleted

class oscar.apps.wishlists.abstract_models.AbstractWishList(*args, **kwargs)[source]

Represents a user’s wish lists of products.

A user can have multiple wish lists, move products between them, etc.

add(product)[source]

Add a product to this wishlist

key

This key acts as primary key and is used instead of an int to make it harder to guess

classmethod random_key(length=6)[source]

Get a unique random generated key

save(*args, **kwargs)[source]

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

class oscar.apps.wishlists.abstract_models.AbstractWishListSharedEmail(*args, **kwargs)[source]

An email which is allowed to view and possibly edit the wishlist, if shared. The user will have to login/create an account with this email in order to view it.

Views

class oscar.apps.customer.wishlists.views.LineMixin[source]

Handles fetching both a wish list and a product Views using this mixin must be passed two keyword arguments:

  • key: The key of a wish list

  • line_pk: The primary key of the wish list line

or

  • product_pk: The primary key of the product

class oscar.apps.customer.wishlists.views.WishListAddProduct(**kwargs)[source]

Adds a product to a wish list.

  • If the user doesn’t already have a wishlist then it will be created for them.

  • If the product is already in the wish list, its quantity is increased.

class oscar.apps.customer.wishlists.views.WishListCreateUpdateViewMixin[source]

The wishlist create and update view have the same approach on saving the wislist and shared email forms. This mixin handles that in the post view, where it will call process_wishlist_forms if both forms are valid. If one of the forms is not valid, the user will be redirected to the original view with form errors.

post(request, *args, **kwargs)[source]

This post method will handle both the create and update view post request.

class oscar.apps.customer.wishlists.views.WishListCreateView(**kwargs)[source]

Create a new wishlist

If a product ID is passed as a kwargs, then this product will be added to the wishlist.

form_class

alias of WishListForm

form_valid(form)[source]

The form argument is actually the wishlist instance because we already saved this in the post method below. This is also why we do not call form.save() here.

get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_form_kwargs()[source]

Return the keyword arguments for instantiating the form.

model

alias of WishList

class oscar.apps.customer.wishlists.views.WishListCreateWithProductView(**kwargs)[source]

Create a wish list and immediately add a product to it

class oscar.apps.customer.wishlists.views.WishListDeleteView(*args, **kwargs)[source]
get_object(queryset=None)[source]

Return the object the view is displaying.

Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

model

alias of WishList

class oscar.apps.customer.wishlists.views.WishListDetailView(**kwargs)[source]

This view acts as a DetailView for a wish list and allows updating the quantities of products.

It is implemented as FormView because it’s easier to adapt a FormView to display a product then adapt a DetailView to handle form validation.

form_class

alias of LineFormFormSet

form_valid(form)[source]

If the form is valid, redirect to the supplied URL.

get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_form_kwargs()[source]

Return the keyword arguments for instantiating the form.

class oscar.apps.customer.wishlists.views.WishListListView(**kwargs)[source]
get_queryset()[source]

Return a list of all the wishlists for the currently authenticated user.

class oscar.apps.customer.wishlists.views.WishListMoveProductToAnotherWishList(**kwargs)[source]
class oscar.apps.customer.wishlists.views.WishListRemoveProduct(*args, **kwargs)[source]
get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_object(queryset=None)[source]

Return the object the view is displaying.

Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

class oscar.apps.customer.wishlists.views.WishListUpdateView(**kwargs)[source]
form_class

alias of WishListForm

form_valid(form)[source]

If the form is valid, save the associated model.

get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_form_kwargs()[source]

Return the keyword arguments for instantiating the form.

get_object(queryset=None)[source]

Return the object the view is displaying.

Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

model

alias of WishList