Skip to content

decorators

Module with all decorators that are exposed for users.

Currently only:

  • property_field - exposing @property like function as field in Model.dict()
  • predefined signals decorators (pre/post + save/update/delete)

post_bulk_update(senders)

Connect given function to all senders for post_bulk_update signal.

Parameters:

Name Type Description Default
senders Union[Type[Model], List[Type[Model]]]

one or a list of "Model" classes that should have the signal receiver registered

required

Returns:

Type Description
Callable

returns the original function untouched

Source code in ormar\decorators\signals.py
176
177
178
179
180
181
182
183
184
185
186
def post_bulk_update(senders: Union[Type["Model"], List[Type["Model"]]]) -> Callable:
    """
    Connect given function to all senders for post_bulk_update signal.

    :param senders: one or a list of "Model" classes
    that should have the signal receiver registered
    :type senders: Union[Type["Model"], List[Type["Model"]]]
    :return: returns the original function untouched
    :rtype: Callable
    """
    return receiver(signal="post_bulk_update", senders=senders)

post_delete(senders)

Connect given function to all senders for post_delete signal.

Parameters:

Name Type Description Default
senders Union[Type[Model], List[Type[Model]]]

one or a list of "Model" classes that should have the signal receiver registered

required

Returns:

Type Description
Callable

returns the original function untouched

Source code in ormar\decorators\signals.py
70
71
72
73
74
75
76
77
78
79
80
def post_delete(senders: Union[Type["Model"], List[Type["Model"]]]) -> Callable:
    """
    Connect given function to all senders for post_delete signal.

    :param senders: one or a list of "Model" classes
    that should have the signal receiver registered
    :type senders: Union[Type["Model"], List[Type["Model"]]]
    :return: returns the original function untouched
    :rtype: Callable
    """
    return receiver(signal="post_delete", senders=senders)

post_relation_add(senders)

Connect given function to all senders for post_relation_add signal.

Parameters:

Name Type Description Default
senders Union[Type[Model], List[Type[Model]]]

one or a list of "Model" classes that should have the signal receiver registered

required

Returns:

Type Description
Callable

returns the original function untouched

Source code in ormar\decorators\signals.py
135
136
137
138
139
140
141
142
143
144
145
def post_relation_add(senders: Union[Type["Model"], List[Type["Model"]]]) -> Callable:
    """
    Connect given function to all senders for post_relation_add signal.

    :param senders: one or a list of "Model" classes
    that should have the signal receiver registered
    :type senders: Union[Type["Model"], List[Type["Model"]]]
    :return: returns the original function untouched
    :rtype: Callable
    """
    return receiver(signal="post_relation_add", senders=senders)

post_relation_remove(senders)

Connect given function to all senders for post_relation_remove signal.

Parameters:

Name Type Description Default
senders Union[Type[Model], List[Type[Model]]]

one or a list of "Model" classes that should have the signal receiver registered

required

Returns:

Type Description
Callable

returns the original function untouched

Source code in ormar\decorators\signals.py
161
162
163
164
165
166
167
168
169
170
171
172
173
def post_relation_remove(
    senders: Union[Type["Model"], List[Type["Model"]]]
) -> Callable:
    """
    Connect given function to all senders for post_relation_remove signal.

    :param senders: one or a list of "Model" classes
    that should have the signal receiver registered
    :type senders: Union[Type["Model"], List[Type["Model"]]]
    :return: returns the original function untouched
    :rtype: Callable
    """
    return receiver(signal="post_relation_remove", senders=senders)

post_save(senders)

Connect given function to all senders for post_save signal.

Parameters:

Name Type Description Default
senders Union[Type[Model], List[Type[Model]]]

one or a list of "Model" classes that should have the signal receiver registered

required

Returns:

Type Description
Callable

returns the original function untouched

Source code in ormar\decorators\signals.py
44
45
46
47
48
49
50
51
52
53
54
def post_save(senders: Union[Type["Model"], List[Type["Model"]]]) -> Callable:
    """
    Connect given function to all senders for post_save signal.

    :param senders: one or a list of "Model" classes
    that should have the signal receiver registered
    :type senders: Union[Type["Model"], List[Type["Model"]]]
    :return: returns the original function untouched
    :rtype: Callable
    """
    return receiver(signal="post_save", senders=senders)

post_update(senders)

Connect given function to all senders for post_update signal.

Parameters:

Name Type Description Default
senders Union[Type[Model], List[Type[Model]]]

one or a list of "Model" classes that should have the signal receiver registered

required

Returns:

Type Description
Callable

returns the original function untouched

Source code in ormar\decorators\signals.py
57
58
59
60
61
62
63
64
65
66
67
def post_update(senders: Union[Type["Model"], List[Type["Model"]]]) -> Callable:
    """
    Connect given function to all senders for post_update signal.

    :param senders: one or a list of "Model" classes
    that should have the signal receiver registered
    :type senders: Union[Type["Model"], List[Type["Model"]]]
    :return: returns the original function untouched
    :rtype: Callable
    """
    return receiver(signal="post_update", senders=senders)

pre_delete(senders)

Connect given function to all senders for pre_delete signal.

Parameters:

Name Type Description Default
senders Union[Type[Model], List[Type[Model]]]

one or a list of "Model" classes that should have the signal receiver registered

required

Returns:

Type Description
Callable

returns the original function untouched

Source code in ormar\decorators\signals.py
109
110
111
112
113
114
115
116
117
118
119
def pre_delete(senders: Union[Type["Model"], List[Type["Model"]]]) -> Callable:
    """
    Connect given function to all senders for pre_delete signal.

    :param senders: one or a list of "Model" classes
    that should have the signal receiver registered
    :type senders: Union[Type["Model"], List[Type["Model"]]]
    :return: returns the original function untouched
    :rtype: Callable
    """
    return receiver(signal="pre_delete", senders=senders)

pre_relation_add(senders)

Connect given function to all senders for pre_relation_add signal.

Parameters:

Name Type Description Default
senders Union[Type[Model], List[Type[Model]]]

one or a list of "Model" classes that should have the signal receiver registered

required

Returns:

Type Description
Callable

returns the original function untouched

Source code in ormar\decorators\signals.py
122
123
124
125
126
127
128
129
130
131
132
def pre_relation_add(senders: Union[Type["Model"], List[Type["Model"]]]) -> Callable:
    """
    Connect given function to all senders for pre_relation_add signal.

    :param senders: one or a list of "Model" classes
    that should have the signal receiver registered
    :type senders: Union[Type["Model"], List[Type["Model"]]]
    :return: returns the original function untouched
    :rtype: Callable
    """
    return receiver(signal="pre_relation_add", senders=senders)

pre_relation_remove(senders)

Connect given function to all senders for pre_relation_remove signal.

Parameters:

Name Type Description Default
senders Union[Type[Model], List[Type[Model]]]

one or a list of "Model" classes that should have the signal receiver registered

required

Returns:

Type Description
Callable

returns the original function untouched

Source code in ormar\decorators\signals.py
148
149
150
151
152
153
154
155
156
157
158
def pre_relation_remove(senders: Union[Type["Model"], List[Type["Model"]]]) -> Callable:
    """
    Connect given function to all senders for pre_relation_remove signal.

    :param senders: one or a list of "Model" classes
    that should have the signal receiver registered
    :type senders: Union[Type["Model"], List[Type["Model"]]]
    :return: returns the original function untouched
    :rtype: Callable
    """
    return receiver(signal="pre_relation_remove", senders=senders)

pre_save(senders)

Connect given function to all senders for pre_save signal.

Parameters:

Name Type Description Default
senders Union[Type[Model], List[Type[Model]]]

one or a list of "Model" classes that should have the signal receiver registered

required

Returns:

Type Description
Callable

returns the original function untouched

Source code in ormar\decorators\signals.py
83
84
85
86
87
88
89
90
91
92
93
def pre_save(senders: Union[Type["Model"], List[Type["Model"]]]) -> Callable:
    """
    Connect given function to all senders for pre_save signal.

    :param senders: one or a list of "Model" classes
    that should have the signal receiver registered
    :type senders: Union[Type["Model"], List[Type["Model"]]]
    :return: returns the original function untouched
    :rtype: Callable
    """
    return receiver(signal="pre_save", senders=senders)

pre_update(senders)

Connect given function to all senders for pre_update signal.

Parameters:

Name Type Description Default
senders Union[Type[Model], List[Type[Model]]]

one or a list of "Model" classes that should have the signal receiver registered

required

Returns:

Type Description
Callable

returns the original function untouched

Source code in ormar\decorators\signals.py
 96
 97
 98
 99
100
101
102
103
104
105
106
def pre_update(senders: Union[Type["Model"], List[Type["Model"]]]) -> Callable:
    """
    Connect given function to all senders for pre_update signal.

    :param senders: one or a list of "Model" classes
    that should have the signal receiver registered
    :type senders: Union[Type["Model"], List[Type["Model"]]]
    :return: returns the original function untouched
    :rtype: Callable
    """
    return receiver(signal="pre_update", senders=senders)