dbbase.model.Model.to_dict

Model.to_dict(to_camel_case=True, level_limits=None, sort=False, serial_fields=None, serial_field_relations=None)[source]

Returns columns in a dict. The point of this is to make a useful default. However, this can’t be expected to cover every possibility, so of course it can be overwritten in any particular model.

Conversion defaults:

date -> %F datetime -> %Y-%m-%d %H:%M:%S Decimal => str

Default:

to_dict(to_camel_case=True, level_limits=None, sort=False)

Parameters
  • to_camel_case (boolean) – dict keys will be converted to camel case.

  • level_limits – (dict : None) : This is more of a technical parameter that is used to limit recursion, but if a class name is listed in the dict, to_dict will not process that class.

  • sort – (bool) : This flag determines whether the keys will be sorted.

  • serial_fields (list) – a list of fields to be substituted for cls.SERIAL_FIELDS

  • serial_field_relations (dict) – To enable a more nuanced control of relations objects, the name of a downstream class and a list of fields to be typically included with the related object.

Returns

(dict) | a dictionary of fields and values