Address

The address app provides core address models - it doesn’t provide any views or other functionality. Of the 5 abstract models, only 2 have a non-abstract version in oscar.apps.address.models - the others are used by the order app to provide shipping and billing address models.

Abstract models

class oscar.apps.address.abstract_models.AbstractAddress(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Superclass address object

This is subclassed and extended to provide models for user, shipping and billing addresses.

Parameters:
  • title (CharField) – Title
  • first_name (CharField) – First name
  • last_name (CharField) – Last name
  • line1 (CharField) – First line of address
  • line2 (CharField) – Second line of address
  • line3 (CharField) – Third line of address
  • line4 (CharField) – City
  • state (CharField) – State/county
  • postcode (CharField) – Post/zip-code
  • country_id (ForeignKey) – Country
  • search_text (CharField) – Search text - used only for searching addresses
active_address_fields()[source]

Returns the non-empty components of the address, but merging the title, first_name and last_name into a single line.

name()[source]

Return the full name

populate_alternative_model(address_model)[source]

For populating an address model using the matching fields from this one.

This is used to convert a user address to a shipping address as part of the checkout process.

salutation()[source]

Return the salutation

summary[source]

Returns a single string summary of the address, separating fields using commas.

class oscar.apps.address.abstract_models.AbstractShippingAddress(*args, **kwargs)[source]

Bases: oscar.apps.address.abstract_models.AbstractAddress

A shipping address.

A shipping address should not be edited once the order has been placed - it should be read-only after that.

Parameters:
  • title (CharField) – Title
  • first_name (CharField) – First name
  • last_name (CharField) – Last name
  • line1 (CharField) – First line of address
  • line2 (CharField) – Second line of address
  • line3 (CharField) – Third line of address
  • line4 (CharField) – City
  • state (CharField) – State/county
  • postcode (CharField) – Post/zip-code
  • country_id (ForeignKey) – Country
  • search_text (CharField) – Search text - used only for searching addresses
  • phone_number (CharField) – Phone number
  • notes (TextField) – For example, leave the parcel in the wheelie bin if I’m not in.
order[source]

Return the order linked to this shipping address

class oscar.apps.address.abstract_models.AbstractUserAddress(*args, **kwargs)[source]

Bases: oscar.apps.address.abstract_models.AbstractShippingAddress

A user’s address. A user can have many of these and together they form an ‘address book’ of sorts for the user.

We use a separate model for shipping and billing (even though there will be some data duplication) because we don’t want shipping/billing addresses changed or deleted once an order has been placed. By having a separate model, we allow users the ability to add/edit/delete from their address book without affecting orders already placed.

Parameters:
  • title (CharField) – Title
  • first_name (CharField) – First name
  • last_name (CharField) – Last name
  • line1 (CharField) – First line of address
  • line2 (CharField) – Second line of address
  • line3 (CharField) – Third line of address
  • line4 (CharField) – City
  • state (CharField) – State/county
  • postcode (CharField) – Post/zip-code
  • country_id (ForeignKey) – Country
  • search_text (CharField) – Search text - used only for searching addresses
  • phone_number (CharField) – Phone number
  • notes (TextField) – For example, leave the parcel in the wheelie bin if I’m not in.
  • user_id (ForeignKey) – User
  • is_default_for_shipping (BooleanField) – Default shipping address?
  • is_default_for_billing (BooleanField) – Default billing address?
  • num_orders (PositiveIntegerField) – Number of orders
  • hash (CharField) – Address hash
  • date_created (DateTimeField) – Date created
generate_hash()[source]

Returns a hash of the address summary

is_default_for_billing = None

Whether this address should be the default for billing.

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

Save a hash of the address fields

class oscar.apps.address.abstract_models.AbstractBillingAddress(*args, **kwargs)[source]

Bases: oscar.apps.address.abstract_models.AbstractAddress

Parameters:
  • title (CharField) – Title
  • first_name (CharField) – First name
  • last_name (CharField) – Last name
  • line1 (CharField) – First line of address
  • line2 (CharField) – Second line of address
  • line3 (CharField) – Third line of address
  • line4 (CharField) – City
  • state (CharField) – State/county
  • postcode (CharField) – Post/zip-code
  • country_id (ForeignKey) – Country
  • search_text (CharField) – Search text - used only for searching addresses
order[source]

Return the order linked to this shipping address

class oscar.apps.address.abstract_models.AbstractCountry(*args, **kwargs)[source]

Bases: django.db.models.base.Model

International Organization for Standardization (ISO) 3166-1 Country list.

Parameters:
  • iso_3166_1_a2 (CharField) – Iso 3166-1 alpha-2
  • iso_3166_1_a3 (CharField) – Iso 3166-1 alpha-3
  • iso_3166_1_numeric (PositiveSmallIntegerField) – Iso 3166-1 numeric
  • name (CharField) – Official name (caps)
  • printable_name (CharField) – Country name
  • is_highlighted (BooleanField) – Is highlighted
  • is_shipping_country (BooleanField) – Is shipping country