Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More
lino.core.fields¶
Defines extended database field classes and utility functions related to fields.
Functions
|
Return the choices for the given field and the given HTTP request whose holder is either a Model, an Actor or an Action. |
|
Raise ValidationError if user enters e.g. a date 30.02.2009. |
Classes
|
An extension of Django's models.CharField. |
Mixin to create a custom field. |
|
|
A DateField that uses a DatePicker instead of a normal DateWidget. |
|
A field that stores |
|
A field that behaves like a DateField, but accepts incomplete dates represented using |
|
A DateField that uses a MonthPicker instead of a normal DateWidget |
|
Stored as plain text in database, but not displayed in user interface. |
|
A field to express a percentage. |
|
|
|
A thin wrapper around Django's DecimalField with price-like default values for decimal_places, max_length and max_digits. |
|
|
|
A field that accepts |
|
Deserves more documentation. |
|
|
|
Like a TimeField, but allowed values are between |
- lino.core.fields.validate_incomplete_date(value)¶
Raise ValidationError if user enters e.g. a date 30.02.2009.
- class lino.core.fields.PasswordField(*args, db_collation=None, **kwargs)¶
Bases:
CharFieldStored as plain text in database, but not displayed in user interface.
- class lino.core.fields.PercentageField(*args, **kwargs)¶
Bases:
DecimalFieldA field to express a percentage. The database stores this like a DecimalField. Plain HTML adds a “%”.
- class lino.core.fields.TimeField(verbose_name=None, name=None, auto_now=False, auto_now_add=False, **kwargs)¶
Bases:
TimeFieldLike a TimeField, but allowed values are between
calendar_start_hourandcalendar_end_hour.
- class lino.core.fields.DatePickerField(verbose_name=None, name=None, auto_now=False, auto_now_add=False, **kwargs)¶
Bases:
DateFieldA DateField that uses a DatePicker instead of a normal DateWidget. Doesn’t yet work.
- class lino.core.fields.MonthField(verbose_name=None, name=None, auto_now=False, auto_now_add=False, **kwargs)¶
Bases:
DateFieldA DateField that uses a MonthPicker instead of a normal DateWidget
- class lino.core.fields.PriceField(verbose_name=None, max_digits=10, **kwargs)¶
Bases:
DecimalFieldA thin wrapper around Django’s DecimalField with price-like default values for decimal_places, max_length and max_digits.
- class lino.core.fields.CharField(*args, **kw)¶
Bases:
CharFieldAn extension of Django’s models.CharField.
Adds two keywords mask_re and strip_chars_re which, when using the ExtJS front end, will be rendered as the maskRe and stripCharsRe config options of TextField as described in the ExtJS documentation, converting naming conventions as follows:
regex
regex
A JavaScript RegExp object to be tested against the field value during validation (defaults to null). If the test fails, the field will be marked invalid using regexText.
mask_re
maskRe
An input mask regular expression that will be used to filter keystrokes that do not match (defaults to null). The maskRe will not operate on any paste events.
strip_chars_re
stripCharsRe
A JavaScript RegExp object used to strip unwanted content from the value before validation (defaults to null).
Example usage:
belgian_phone_no = dd.CharField(max_length=15, strip_chars_re='')
- class lino.core.fields.QuantityField(*args, **kw)¶
Bases:
CharFieldA field that accepts
Quantity,PercentageandDurationvalues.Implemented as a CharField, which means that sorting or filter ranges may not work as expected, and you cannot use SUM or AVG agregators on quantity fields since the database does not know how to calculate sums from them.
When you set blank=True, then you should also set null=True.
- to_python(value)¶
Excerpt from Django docs:
As a general rule,
to_python()should deal gracefully with any of the following arguments:An instance of the correct type (e.g., Hand in our ongoing example).
A string (e.g., from a deserializer).
None (if the field allows null=True)
I’d add “Any value allowed for this field when instantiating a model.”
- class lino.core.fields.DurationField(*args, **kw)¶
Bases:
QuantityFieldA field that stores
Durationvalues as CHAR.
- class lino.core.fields.IncompleteDateField(*args, **kw)¶
Bases:
CharFieldA field that behaves like a DateField, but accepts incomplete dates represented using
lino.utils.format_date.IncompleteDate.
- class lino.core.fields.RecurrenceField(*args, **kw)¶
Bases:
CharFieldDeserves more documentation.
- class lino.core.fields.CustomField¶
Bases:
objectMixin to create a custom field.
It defines a single method
create_layout_elem().- create_layout_elem(base_class, layout_handle, field, **kw)¶
Return the widget to represent this field in the specified layout_handle.
The widget must be an instance of the given base_class.
self and field are identical unless self is a
RemoteFieldor aVirtualField.
- lino.core.fields.choices_for_field(ar, holder, field)¶
Return the choices for the given field and the given HTTP request whose holder is either a Model, an Actor or an Action.