Sri Lanka (lk)

Forms

Sri Lanka specific Form helpers.

class localflavor.lk.forms.LKDistrictSelect(attrs=None)[source]

A Select widget with option to select a districts from list of all districts of Sri Lanka.

Added in version 5.0.

class localflavor.lk.forms.LKPostalCodeFormField(**kwargs)[source]

A form field that accepts Sri Lanka postal code. Format : NNNNN

Postal codes: https://en.wikipedia.org/wiki/Postal_codes_in_Sri_Lanka

Added in version 5.0.

class localflavor.lk.forms.LKProvinceSelect(attrs=None)[source]

A Select widget with option to select a provinces from list of all provinces of Sri Lanka.

Added in version 5.0.

Models

Sri Lanka specific Model fields

class localflavor.lk.models.LKDistrictField(*args, **kwargs)[source]

A model field that provides an option to select a district from the list of all Sri Lanka districts.

Added in version 5.0.

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.

class localflavor.lk.models.LKPostalCodeField(*args, **kwargs)[source]

A model field that accepts Sri Lanka postal codes. Format: NNNNN Source: https://en.wikipedia.org/wiki/Postal_codes_in_Sri_Lanka

Added in version 5.0.

formfield(**kwargs)[source]

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

class localflavor.lk.models.LKPostalCodeValidator(*args, **kwargs)[source]

A validator for Sri Lanka Postal Codes.

class localflavor.lk.models.LKProvinceField(*args, **kwargs)[source]

A model field that provides an option to select a province from the list of all Sri Lanka provinces.

Added in version 5.0.

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.

Data

localflavor.lk.lk_provinces.PROVINCES = [('central', 'Central'), ('eastern', 'Eastern'), ('north_central', 'North Central'), ('north_western', 'North Western'), ('northern', 'Northern'), ('sabaragamuwa', 'Sabaragamuwa'), ('southern', 'Southern'), ('uva', 'Uva'), ('western', 'Western')]

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

localflavor.lk.lk_districts.DISTRICTS = [('alambil', 'Alambil'), ('ampara', 'Ampara'), ('anuradhapura', 'Anuradhapura'), ('badulla', 'Badulla'), ('batticaloa', 'Batticaloa'), ('colombo', 'Colombo'), ('galle', 'Galle'), ('gampaha', 'Gampaha'), ('hambanthota', 'Hambanthota'), ('jaffna', 'Jaffna'), ('kaluthara', 'Kaluthara'), ('kandy', 'Kandy'), ('kegalle', 'Kegalle'), ('kilinochchi', 'Kilinochchi'), ('kurunagala', 'Kurunagala'), ('mannar', 'Mannar'), ('matale', 'Matale'), ('mathara', 'Mathara'), ('monaragala', 'Monaragala'), ('mullativu', 'Mullativu'), ('nuwara_eliya', 'Nuwara Eliya'), ('polonnaruwa', 'Polonnaruwa'), ('puttalam', 'Puttalam'), ('rathnapura', 'Rathnapura'), ('trincomalee', 'Trincomalee'), ('vavuniya', 'Vavuniya')]

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.