Norway (no)

Forms

Norwegian-specific Form helpers.

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

A form field for Norwegian bank account numbers.

Performs MOD11 with the custom weights for the Norwegian bank account numbers, including a check for a remainder of 0, in which event the checksum is also 0.

Usually their string representation is along the lines of ZZZZ.YY.XXXXX, where the last X is the check digit. They’re always a total of 11 digits long, with 10 out of these 11 being the actual account number itself.

  • Accepts, and strips, account numbers with extra spaces.
  • Accepts, and strips, account numbers provided in form of XXXX.YY.XXXXX.

Note

No consideration is taking for banking clearing numbers as of yet, seeing as these are only used between banks themselves.

New in version 1.5.

to_python(value)[source]

Return a string.

class localflavor.no.forms.NOMunicipalitySelect(attrs=None)[source]

A Select widget that uses a list of Norwegian municipalities (fylker) as its choices.

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

Algorithm is documented at http://no.wikipedia.org/wiki/Personnummer.

clean(value)[source]

Validate the given value and return its “cleaned” value as an appropriate Python object. Raise ValidationError for any errors.

class localflavor.no.forms.NOZipCodeField(**kwargs)[source]

A form field that validates input as a Norwegian zip code.

Valid codes have four digits.

Data

localflavor.no.no_municipalities.MUNICIPALITY_CHOICES = (('akershus', 'Akershus'), ('austagder', 'Aust-Agder'), ('buskerud', 'Buskerud'), ('finnmark', 'Finnmark'), ('hedmark', 'Hedmark'), ('hordaland', 'Hordaland'), ('janmayen', 'Jan Mayen'), ('moreogromsdal', 'Møre og Romsdal'), ('nordtrondelag', 'Nord-Trøndelag'), ('nordland', 'Nordland'), ('oppland', 'Oppland'), ('oslo', 'Oslo'), ('rogaland', 'Rogaland'), ('sognogfjordane', 'Sogn og Fjordane'), ('svalbard', 'Svalbard'), ('sortrondelag', 'Sør-Trøndelag'), ('telemark', 'Telemark'), ('troms', 'Troms'), ('vestagder', 'Vest-Agder'), ('vestfold', 'Vestfold'), ('ostfold', 'Østfold'))

An alphabetical list of Norwegian municipalities (fylker) for use as choices in a formfield.