Db Field Types
This page describes the available field types that can be used in model definitions.
Nullability and Defaults (read this first)
- Any field can be marked
null=True. - If a field is
null=True, its generated VBA getter/setter will useVariant. This weakens type safety and invites “unknowns” into calculations. Prefer avoidingnull=Truewhen you can.
Pragmatic null alternative: irrational defaults
Rather than null=True, assign an obviously nonsensical default, which cannot be confused with a real value. This preserves strongly typed getters/setters, while still expressing “missing”.
- Example: a concluded rent or cap rate could be wired with default to
-1or-0.01. These are impossible as real values, so they are unmistakably “missing”, yet still numeric— which lets most formulas continue to flow.
IdField
Every model is automatically assigned an IdField. This field cannot be edited or deleted.
VariantField
A flexible field that can store multiple types (string, number, boolean, date) as needed.
VariantField is great when sketching out a project and experimenting. Over the long run, it's far better to switch to an explicit type (e.g. prefer to use DateField instead of VariantField). Explicit field types allow the VBA compiler to detect bugs instantly, before the code even runs.
CharField
Short, single-line text input.
Use when the value is bounded in length (e.g., street_address, zip_code).
TextField
Large, free-form text content (e.g., comments, notes).
Automatically renders as a multi-line input in the Generic Edit form.
BooleanField
Stores True/False values.
Automatically renders as a dropdown offering choices True/False in the Generic Edit form.
NOTE if a BooleanField is set null=True, the dropdown will offer True/False/<blank>
DateField
Use DateField for real-world dates such as lease start, contract signed, or expiration.
If a broader range is needed (e.g., historical dates), store as text or use a sentinel default.
WARNING: Excel’s internal date system cannot store values earlier than January 1, 1900. Any attempt to assign earlier dates will error (with a clear error message).
FloatField
Floating-point numbers (e.g., 2.343).
Use when decimal precision is required (e.g., cap rates, percentages).
IntegerField
Whole numbers (positive or negative).
Saves memory relative to FloatField when decimal precision is not required.
PositiveIntegerField
Whole numbers greater than or equal to zero.
Behaves like IntegerField but errors if a negative value is saved.
CustomValidated
Field with custom validation rules.
Custom validation is specified by defining Xl Data Validation in the Topmost Data Cell (one below the header row) on the Db Table Worksheet
NOTE: This field requires data validation applied in the top data cell.
If validation is missing, the Add-in automatically raises an error.
ForeignKey
Links one record to another model (many-to-one).
Implements the standard relational pattern: each record in this model points to a single record in the target model.
For example 'apartment_unit.parent_property' would be a ForeignKey relation.
ManyToManyField
Defines a many-to-many relationship between models.
For example, apartment_property.amenities would be a ManyToManyField relation.