fairdm.forms.fields#
Form fields and widgets for partial dates, quantities and fixed-precision decimals.
Module Contents#
Classes#
Date select widget that orders year, month, day and accepts partial dates. |
|
Field with separate year, month and day selects for a |
|
Text field for a partial date typed as |
|
Hand the number input and unit select a stored quantity in the field’s base units. |
|
django-pint’s float quantity form field, showing stored values in base units. |
|
django-pint’s integer quantity form field, showing stored values in base units. |
|
django-pint’s decimal quantity form field, showing stored values in base units. |
|
Decimal field whose input is masked to the allowed integer and decimal places. |
|
Decimal field for a latitude, masked to seven digits with five decimal places. |
|
Decimal field for a longitude, masked to eight digits with five decimal places. |
API#
- class PartialDateWidget(attrs=None, years=None, months=None, empty_label=None)[source]#
Bases:
django.forms.SelectDateWidgetDate select widget that orders year, month, day and accepts partial dates.
Args: attrs: HTML attributes for the rendered selects. years: Years offered in the year select. Defaults to 1900 through the current year, newest first. months: Months offered in the month select. empty_label: Label of the empty choice in each select.
Initialization
- class PartialDateFormField(*, max_length=None, min_length=None, strip=True, empty_value='', **kwargs)[source]#
Bases:
django.forms.CharFieldField with separate year, month and day selects for a
PartialDateField.Initialization
- widget#
None
- class PartialDateField(*, max_length=None, min_length=None, strip=True, empty_value='', **kwargs)[source]#
Bases:
django.forms.CharFieldText field for a partial date typed as
yyyy-mm-dd, with a masked input.Initialization
- widget#
‘TextInput(…)’
- class QuantityFormFieldMixin[source]#
Hand the number input and unit select a stored quantity in the field’s base units.
django-pint’s form field hands its widget the quantity itself, and the widget names the unit the way pint prints it (“meter”). That matches none of the unit choices when the field spells its units short (“m”), so the select shows no unit and an unchanged form fails to save.
- class QuantityFormField(*args, **kwargs)[source]#
Bases:
fairdm.forms.fields.QuantityFormFieldMixin,quantityfield.fields.QuantityFormFielddjango-pint’s float quantity form field, showing stored values in base units.
Initialization
- class IntegerQuantityFormField(*args, **kwargs)[source]#
Bases:
fairdm.forms.fields.QuantityFormFieldMixin,quantityfield.fields.IntegerQuantityFormFielddjango-pint’s integer quantity form field, showing stored values in base units.
Initialization
- class DecimalQuantityFormField(*args, **kwargs)[source]#
Bases:
fairdm.forms.fields.QuantityFormFieldMixin,quantityfield.fields.DecimalQuantityFormFielddjango-pint’s decimal quantity form field, showing stored values in base units.
Initialization
- class DecimalField(*, max_value=None, min_value=None, max_digits=None, decimal_places=None, **kwargs)[source]#
Bases:
django.forms.DecimalFieldDecimal field whose input is masked to the allowed integer and decimal places.
Args: max_value: Accepted for signature compatibility but not applied. min_value: Accepted for signature compatibility but not applied. max_digits: Total number of digits allowed. Required. decimal_places: Number of digits after the decimal point. Required. **kwargs: Passed to :class:
django.forms.DecimalField.Attributes: widget: The widget class, a plain text input carrying the mask.
Raises: ValueError:
max_digitsordecimal_placesis missing.Initialization
- widget#
None
- class LatitudeField(*args, max_digits=7, decimal_places=5, **kwargs)[source]#
Bases:
fairdm.forms.fields.DecimalFieldDecimal field for a latitude, masked to seven digits with five decimal places.
Args: *args: Passed to :class:
DecimalField. max_digits: Total number of digits allowed. decimal_places: Number of digits after the decimal point. **kwargs: Passed to :class:DecimalField.Initialization
- class LongitudeField(*args, max_digits=8, decimal_places=5, **kwargs)[source]#
Bases:
fairdm.forms.fields.DecimalFieldDecimal field for a longitude, masked to eight digits with five decimal places.
Args: *args: Passed to :class:
DecimalField. max_digits: Total number of digits allowed. decimal_places: Number of digits after the decimal point. **kwargs: Passed to :class:DecimalField.Initialization