Fields

knackpy.fields #

FieldDef Objects #

class FieldDef()

Knack field defintion wrapper

Field Objects #

class Field(object)

A container for a single column of Knack data. This is the lowest-level container in the API. The hieracrchy being: App > Records > Record > Field. Typically you would not construct this class directly, but instead an App, which will generate Fields via App.records().

More specifically, the API is designed so that you would typically interface with a Field instance through the records.Record class. That class operates on Fields by returning their values through Record[] or Record[].

But it’s fine to work directly with fields:

  • field.value: the unformatted input value
  • field.formatted: the formatted value
  • field.key: the knack field key
  • field.name: the knack field name

Arguments:

  • field_def knackpy.fields.FieldDef - A knackpy FieldDef class object
  • value object - Anything, really.
  • timezone [pytz.timezone] - A pytz timezone object.
  • knack_formatted_value str, optional - There a fiew fields where it’s easier to use knack’s formatted value as a starting point, rather than the raw value. E.g. timer and name. In those cases, we assign that value here and pass it on to the self.formatter() function for further formatting.