Australia (au)

Forms

Australian-specific Form helpers.

class localflavor.au.forms.AUBusinessNumberField(*, max_length=None, min_length=None, strip=True, empty_value='', **kwargs)[source]

A form field that validates input as an Australian Business Number (ABN).

New in version 1.3.

Changed in version 1.4.

prepare_value(value)[source]

Format the value for display.

to_python(value)[source]

Return a string.

class localflavor.au.forms.AUCompanyNumberField(*, max_length=None, min_length=None, strip=True, empty_value='', **kwargs)[source]

A form field that validates input as an Australian Company Number (ACN).

New in version 1.5.

prepare_value(value)[source]

Format the value for display.

to_python(value)[source]

Return a string.

class localflavor.au.forms.AUPostCodeField(max_length=4, **kwargs)[source]

Australian post code field.

Assumed to be 4 digits. Northern Territory 3-digit postcodes should have leading zero.

class localflavor.au.forms.AUStateSelect(attrs=None)[source]

A Select widget that uses a list of Australian states/territories as its choices.

class localflavor.au.forms.AUTaxFileNumberField(*, max_length=None, min_length=None, strip=True, empty_value='', **kwargs)[source]

A form field that validates input as an Australian Tax File Number (TFN).

New in version 1.4.

prepare_value(value)[source]

Format the value for display.

Models

class localflavor.au.models.AUBusinessNumberField(*args, **kwargs)[source]

A model field that checks that the value is a valid Australian Business Number (ABN).

New in version 1.3.

description = 'Australian Business Number'
formfield(**kwargs)[source]

Return a django.forms.Field instance for this field.

to_python(value)[source]

Ensure the ABN is stored without spaces.

validators = [<localflavor.au.validators.AUBusinessNumberFieldValidator object>, <django.core.validators.MaxLengthValidator object>]
class localflavor.au.models.AUCompanyNumberField(*args, **kwargs)[source]

A model field that checks that the value is a valid Australian Company Number (ACN).

New in version 1.5.

description = 'Australian Company Number'
formfield(**kwargs)[source]

Return a django.forms.Field instance for this field.

to_python(value)[source]

Ensure the ACN is stored without spaces.

validators = [<localflavor.au.validators.AUCompanyNumberFieldValidator object>, <django.core.validators.MaxLengthValidator object>]
class localflavor.au.models.AUPostCodeField(*args, **kwargs)[source]

A model field that stores the four-digit Australian postcode in the database.

This field is represented by forms as a AUPostCodeField field.

description = 'Australian Postcode'
formfield(**kwargs)[source]

Return a django.forms.Field instance for this field.

class localflavor.au.models.AUStateField(*args, **kwargs)[source]

A model field that stores the three-letter Australian state abbreviation in the database.

It is represented with STATE_CHOICES` choices.

deconstruct()[source]

Return enough information to recreate the field as a 4-tuple:

  • The name of the field on the model, if contribute_to_class() has been run.
  • The import path of the field, including the class:e.g. django.db.models.IntegerField This should be the most portable version, so less specific may be better.
  • A list of positional arguments.
  • A dict of keyword arguments.

Note that the positional or keyword arguments must contain values of the following types (including inner values of collection types):

  • None, bool, str, int, float, complex, set, frozenset, list, tuple, dict
  • UUID
  • datetime.datetime (naive), datetime.date
  • top-level classes, top-level functions - will be referenced by their full import path
  • Storage instances - these have their own deconstruct() method

This is because the values here must be serialized into a text format (possibly new Python code, possibly JSON) and these are the only types with encoding handlers defined.

There’s no need to return the exact way the field was instantiated this time, just ensure that the resulting field is the same - prefer keyword arguments over positional ones, and omit parameters with their default values.

description = 'Australian State'
class localflavor.au.models.AUTaxFileNumberField(*args, **kwargs)[source]

A model field that checks that the value is a valid Tax File Number (TFN).

A TFN is a number issued to a person by the Commissioner of Taxation and is used to verify client identity and establish their income levels. It is a eight or nine digit number without any embedded meaning.

New in version 1.4.

description = 'Australian Tax File Number'
formfield(**kwargs)[source]

Return a django.forms.Field instance for this field.

to_python(value)[source]

Ensure the TFN is stored without spaces.

validators = [<localflavor.au.validators.AUTaxFileNumberFieldValidator object>, <django.core.validators.MaxLengthValidator object>]

Data

localflavor.au.au_states.STATE_CHOICES = (('ACT', 'Australian Capital Territory'), ('NSW', 'New South Wales'), ('NT', 'Northern Territory'), ('QLD', 'Queensland'), ('SA', 'South Australia'), ('TAS', 'Tasmania'), ('VIC', 'Victoria'), ('WA', 'Western Australia'))

An alphabetical list of states for use as choices in a formfield.