lck.django 0.8.5 documentation
Note
The legacy lck.django.choices namespace will be removed in lck.django 1.0. Use dj.choices.
Creates a list of pairs from the specified Choices class. By default, each pair consists of a numeric ID and the translated description. If use_ids is False, the name of the attribute is used instead of the numeric ID.
If filter is specified, it’s a set or sequence of attribute names that should be included in the list. Note that the numeric IDs are the same regardless of the filtering. This is useful for predefining a large set of possible values and filtering to only the ones which are currently implemented.
Given the name, returns the choice object. Unless fallback is set, raises ValueError if name not present.
Given the name, returns the id. Unless fallback is set, raises ValueError if name not present.
Given the name, returns the localized description string. Unless fallback is set, raises ValueError if name not present.
Given the name, returns the raw description string. Unless fallback is set, raises ValueError if name not present.
Given the id, returns the choice object. Unless fallback is set, raises ValueError if name not present.
Given the id, returns the attribute name. Unless fallback is set, raises ValueError if name not present.
Given the id, returns the localized description string. Unless fallback is set, raises ValueError if name not present.
Given the id, returns the raw description string. Unless fallback is set, raises ValueError if name not present.
Converts a sequence of choices to a sequence of choice IDs.
Converts a sequence of choices to a sequence of choice names.
alias of ChoiceGroup
Choices.from_name(name, fallback=unset) -> choice object
Given the name, returns the choice object. Unless fallback is set, raises ValueError if name not present.
Choices.id_from_name(name, fallback=unset) -> id
Given the name, returns the id. Unless fallback is set, raises ValueError if name not present.
Choices.desc_from_name(name, fallback=unset) -> localized description string
Given the name, returns the localized description string. Unless fallback is set, raises ValueError if name not present.
Choices.raw_from_name(name, fallback=unset) -> raw description string
Given the name, returns the raw description string. Unless fallback is set, raises ValueError if name not present.
Choices.from_id(id, fallback=unset) -> choice object
Given the id, returns the choice object. Unless fallback is set, raises ValueError if name not present.
Choices.name_from_id(id, fallback=unset) -> attribute name
Given the id, returns the attribute name. Unless fallback is set, raises ValueError if name not present.
Choices.desc_from_id(id, fallback=unset) -> localized description string
Given the id, returns the localized description string. Unless fallback is set, raises ValueError if name not present.
Choices.raw_from_id(id, fallback=unset) -> raw description string
Given the id, returns the raw description string. Unless fallback is set, raises ValueError if name not present.
Converts a sequence of choices to a sequence of choice IDs.
Converts a sequence of choices to a sequence of choice names.
A single choice.
int.bit_length() -> int
Number of bits necessary to represent self in binary. >>> bin(37) ‘0b100101’ >>> (37).bit_length() 6
Returns self, the complex conjugate of any int.
the denominator of a rational number in lowest terms
Enables adding custom attributes to choices at declaration time. For example:
class Color(Choices):
_ = Choices.Choice
red = _("red").extra(html='#ff0000')
green = _("green").extra(html='#00ff00')
blue = _("blue").extra(html='#0000ff')
Later on you can use the defined attribute directly:
>>> Color.red.html
'#ff0000'
or with choices received using the getters:
>>> Color.from_name(request.POST['color']).html
'#00ff00'
the imaginary part of a complex number
the numerator of a rational number in lowest terms
the real part of a complex number
A group of choices.
int.bit_length() -> int
Number of bits necessary to represent self in binary. >>> bin(37) ‘0b100101’ >>> (37).bit_length() 6
Returns self, the complex conjugate of any int.
the denominator of a rational number in lowest terms
Enables adding custom attributes to choices at declaration time. For example:
class Color(Choices):
_ = Choices.Choice
red = _("red").extra(html='#ff0000')
green = _("green").extra(html='#00ff00')
blue = _("blue").extra(html='#0000ff')
Later on you can use the defined attribute directly:
>>> Color.red.html
'#ff0000'
or with choices received using the getters:
>>> Color.from_name(request.POST['color']).html
'#00ff00'
the imaginary part of a complex number
the numerator of a rational number in lowest terms
the real part of a complex number
Specifies a set for all countries of the world (as of January 2011), including unions, parts of United Kingdom and unrecognized states.
Officially recognized states, as of January 2011.
Parts of United Kingdom.
De facto countries that are not globally recognized.
Commonly referred unions and associations.
Specifies a broad set of languages. Uses a superset of values found in Django and Firefox sources.
Given the name, returns the choice object. Unless fallback is set, raises ValueError if name not present. If the given name has - characters, they are converted to _ for lookup purposes. If no language is found, a more generic language lookup is tried (e.g. for "pl-pl" also "pl" will be attempted) before raising ValueError or returning the fallback value.
Given the name, returns the id. Unless fallback is set, raises ValueError if name not present. If the given name has - characters, they are converted to _ for lookup purposes. If no language is found, a more generic language lookup is tried (e.g. for "pl-pl" also "pl" will be attempted) before raising ValueError or returning the fallback value.
Given the name, returns the localized description string. Unless fallback is set, raises ValueError if name not present. If the given name has - characters, they are converted to _ for lookup purposes. If no language is found, a more generic language lookup is tried (e.g. for "pl-pl" also "pl" will be attempted) before raising ValueError or returning the fallback value.
Given the name, returns the raw description string. Unless fallback is set, raises ValueError if name not present. If the given name has - characters, they are converted to _ for lookup purposes. If no language is found, a more generic language lookup is tried (e.g. for "pl-pl" also "pl" will be attempted) before raising ValueError or returning the fallback value.
Choices.from_name(name, fallback=unset) -> choice object
Given the name, returns the choice object. Unless fallback is set, raises ValueError if name not present. If the given name has - characters, they are converted to _ for lookup purposes. If no language is found, a more generic language lookup is tried (e.g. for "pl-pl" also "pl" will be attempted) before raising ValueError or returning the fallback value.
Choices.id_from_name(name, fallback=unset) -> id
Given the name, returns the id. Unless fallback is set, raises ValueError if name not present. If the given name has - characters, they are converted to _ for lookup purposes. If no language is found, a more generic language lookup is tried (e.g. for "pl-pl" also "pl" will be attempted) before raising ValueError or returning the fallback value.
Choices.desc_from_name(name, fallback=unset) -> localized description string
Given the name, returns the localized description string. Unless fallback is set, raises ValueError if name not present. If the given name has - characters, they are converted to _ for lookup purposes. If no language is found, a more generic language lookup is tried (e.g. for "pl-pl" also "pl" will be attempted) before raising ValueError or returning the fallback value.
Choices.raw_from_name(name, fallback=unset) -> raw description string
Given the name, returns the raw description string. Unless fallback is set, raises ValueError if name not present. If the given name has - characters, they are converted to _ for lookup purposes. If no language is found, a more generic language lookup is tried (e.g. for "pl-pl" also "pl" will be attempted) before raising ValueError or returning the fallback value.