Menu
Introduction
Getting Started
Developer guide
Release
Architecture
CLI
Technical documentations
Version
Publication date

Mar 9, 2022

Confidentiality
Public
Reactions
1
Share

NullableDeferredForeignKeyField

DeferredForeignKey (null=True) whose instance value is typed Model | None.

The related model is referenced by string name (the FK is resolved later, once all tables exist), so its type cannot be inferred from the argument: specialize the generic explicitly. The related class is usually not importable here — that is the reason the FK is deferred — so import it under TYPE_CHECKING and use it as a forward reference:

if TYPE_CHECKING:
    from ...other_model import OtherModel

ref = NullableDeferredForeignKeyField["OtherModel"](
    "OtherModel", backref="+", lazy_load=False
)                                                        # -> OtherModel | None
Functions
__init__

Initialize self. See help(type(self)) for accurate signature.

rel_model_name : str
adapt
value : Any
alias
alias : Any
asc
collation : Any
nulls : Any
between
lo : Any
hi : Any
bin_and
rhs : Any
bin_or
rhs : Any
bind
model : Any
name : Any
set_attribute : bool - True
bind_to
dest : Any
cast
as_type : Any
clone
coerce
_coerce : bool - True
collate
collation : Any
concat
rhs : Any
contains
rhs : Any
converter
db_value
value : Any
ddl
ctx : Any
ddl_datatype
ctx : Any
desc
collation : Any
nulls : Any
distinct
endswith
rhs : Any
get_modifiers
get_sort_key
ctx : Any
ilike
rhs : Any
in_
rhs : Any
iregexp
rhs : Any
is_alias
is_null
is_null : bool - True
like
rhs : Any
not_in
rhs : Any
python_value
value : Any
regexp
rhs : Any
set_model
rel_model : Any
startswith
rhs : Any
to_value
value : Any
unalias
unwrap
copy @staticmethod
method : Any
resolve @staticmethod
model_cls : Any
Shine Logo
Technical bricks to reuse or customize

Have you developed a brick?

Share it to accelerate projects for the entire community.