Sweden (se)

Forms

Swedish specific Form helpers

class localflavor.se.forms.SECountySelect(attrs=None)[source]

A Select form widget that uses a list of the Swedish counties (län) as its choices.

The cleaned value is the official county code – see http://en.wikipedia.org/wiki/Counties_of_Sweden for a list.

class localflavor.se.forms.SEOrganisationNumberField(max_length=None, min_length=None, *args, **kwargs)[source]

A form field that validates input as a Swedish organisation number (organisationsnummer).

It accepts the same input as SEPersonalIdentityField (for sole proprietorships (enskild firma). However, co-ordination numbers are not accepted.

It also accepts ordinary Swedish organisation numbers with the format NNNNNNNNNN.

The return value will be YYYYMMDDXXXX for sole proprietors, and NNNNNNNNNN for other organisations.

class localflavor.se.forms.SEPersonalIdentityNumberField(coordination_number=True, *args, **kwargs)[source]

A form field that validates input as a Swedish personal identity number (personnummer).

The correct formats are YYYYMMDD-XXXX, YYYYMMDDXXXX, YYMMDD-XXXX, YYMMDDXXXX and YYMMDD+XXXX.

A + indicates that the person is older than 100 years, which will be taken into consideration when the date is validated.

The checksum will be calculated and checked. The birth date is checked to be a valid date.

By default, co-ordination numbers (samordningsnummer) will be accepted. To only allow real personal identity numbers, pass the keyword argument coordination_number=False to the constructor.

The cleaned value will always have the format YYYYMMDDXXXX.

class localflavor.se.forms.SEPostalCodeField(*args, **kwargs)[source]

A form field that validates input as a Swedish postal code (postnummer). Valid codes consist of five digits (XXXXX). The number can optionally be formatted with a space after the third digit (XXX XX).

The cleaned value will never contain the space.

Utilities

localflavor.se.utils.id_number_checksum(gd)[source]

Calculates a Swedish ID number checksum, using the “Luhn”-algoritm

localflavor.se.utils.validate_id_birthday(gd, fix_coordination_number_day=True)[source]

Validates the birth_day and returns the datetime.date object for the birth_day.

If the date is an invalid birth day, a ValueError will be raised.

Data

localflavor.se.se_counties.COUNTY_CHOICES = ((u'AB', <django.utils.functional.__proxy__ object at 0x7f1e9e20ee10>), (u'AC', <django.utils.functional.__proxy__ object at 0x7f1e9e08a090>), (u'BD', <django.utils.functional.__proxy__ object at 0x7f1e9e08a7d0>), (u'C', <django.utils.functional.__proxy__ object at 0x7f1e9e08a350>), (u'D', <django.utils.functional.__proxy__ object at 0x7f1e9e08a650>), (u'E', <django.utils.functional.__proxy__ object at 0x7f1e9e08aa10>), (u'F', <django.utils.functional.__proxy__ object at 0x7f1e9e08a590>), (u'G', <django.utils.functional.__proxy__ object at 0x7f1e9e08acd0>), (u'H', <django.utils.functional.__proxy__ object at 0x7f1e9e08ab50>), (u'I', <django.utils.functional.__proxy__ object at 0x7f1e9e08a810>), (u'K', <django.utils.functional.__proxy__ object at 0x7f1e9e08a6d0>), (u'M', <django.utils.functional.__proxy__ object at 0x7f1e9e08a850>), (u'N', <django.utils.functional.__proxy__ object at 0x7f1e9e08a5d0>), (u'O', <django.utils.functional.__proxy__ object at 0x7f1e9e08a190>), (u'S', <django.utils.functional.__proxy__ object at 0x7f1e9d326410>), (u'T', <django.utils.functional.__proxy__ object at 0x7f1e9d3269d0>), (u'U', <django.utils.functional.__proxy__ object at 0x7f1e9d326650>), (u'W', <django.utils.functional.__proxy__ object at 0x7f1e9d326990>), (u'X', <django.utils.functional.__proxy__ object at 0x7f1e9d326790>), (u'Y', <django.utils.functional.__proxy__ object at 0x7f1e9d3261d0>), (u'Z', <django.utils.functional.__proxy__ object at 0x7f1e9d326390>))

An alphabetical list of Swedish counties, sorted by codes. http://en.wikipedia.org/wiki/Counties_of_Sweden