property_field
property_field(func)
Decorator to set a property like function on Model to be exposed as field in dict() and fastapi response. Although you can decorate a @property field like this and this will work, mypy validation will complain about this. Note that "fields" exposed like this do not go through validation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func |
Callable
|
decorated function to be exposed |
required |
Returns:
Type | Description |
---|---|
Union[property, Callable]
|
decorated function passed in func param, with set property_field = True |
Raises:
Type | Description |
---|---|
ModelDefinitionError
|
if method has any other argument than self. |
Source code in ormar\decorators\property_field.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|