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.
- key¶
This key acts as primary key and is used instead of an int to make it harder to guess
- 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.
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.
- 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
oscar.apps.wishlists.forms.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.
- model¶
alias of
oscar.apps.wishlists.models.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(**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.
- model¶
alias of
oscar.apps.wishlists.models.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
django.forms.formsets.LineFormFormSet
- class oscar.apps.customer.wishlists.views.WishListUpdateView(**kwargs)[source]¶
- form_class¶
alias of
oscar.apps.wishlists.forms.WishListForm
- 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.
- model¶
alias of
oscar.apps.wishlists.models.WishList