classifier.models

ClassifierAbstract

class classifier.models.ClassifierAbstract(*args, **kwargs)[source]

Base class to create classifier models. Will provide base data and functions like validation and to_python (convert from string to real type).

In simplest case should be created model just inherited from this abstract model without extra code.

kind - custom identificator for classifier type (like: phone) value_type - expected type of value (like: string) value_validator - regex to validate extered value (like: +d{12}) only_one_required - checkmark to make one on available lables required

Supported types: int, float, string, boolean, date, datatime.

Labels with kind give posibility to create one type of record with different names, like kind is phone and available lables are “Mobile”, “Home”, “Work” etc.

kind

custom identificator for classifier type (like: phone)

value_type

expected type of value (like: string)

value_validator

regex to validate extered value (like: +d{12})

only_one_required

checkmark to make one on available lables required

to_python(value)[source]

run convertor from string to type in value_type field

ClassifierLabelAbstract

class classifier.models.ClassifierLabelAbstract(*args, **kwargs)[source]

Base model class to define several human readable names for each classifier kind.

label

human redable label for data

required

checkmark to make label required

get_classifier_instance()[source]
Returns:instance of related classifier
Returns:field related to model inherited from ClassifierAbstract.
Raises:ClassifierModelNotFound – if related field wasn’t found

Caution

not field name

classmethod get_classifier_model()[source]
Returns:related model inherited from ClassifierAbstract