relation_kind
Kinds of relation fields: which side of a relation a field is and how many
related models it holds. Each field class reports its own kind, so code that
needs to know whether a relation holds a list or a single model asks the
field's kind instead of combining the virtual / is_multi /
is_through flags itself. Fields that aren't relations report
NOT_A_RELATION.
FOREIGN_KEY_KINDS = {(False, False): FORWARD_FOREIGN_KEY, (False, True): REVERSE_FOREIGN_KEY, (True, False): FORWARD_ONE_TO_ONE, (True, True): REVERSE_ONE_TO_ONE}
module-attribute
Kind of a foreign key field by its (one_to_one, virtual) flags.
RelationKind
dataclass
Kind of a relation field.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
kind name, for messages and debugging |
many |
bool
|
whether the field holds a list of related models |
holds_columns |
bool
|
whether the field stores the relation in columns of its own model (the forward side of a foreign key or one-to-one) |
Source code in ormar/fields/relation_kind.py
| Python | |
|---|---|
13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |