related_names_validation
validate_related_names_in_relations(model_fields, new_model)
Performs a validation of relation_names in relation fields. If multiple fields are leading to the same related model only one can have empty related_name param (populated by default as model.name.lower()+'s'). Also related_names have to be unique for given related model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_fields |
Dict
|
dictionary of declared ormar model fields |
required |
new_model |
Type[Model]
|
|
required |
Raises:
Type | Description |
---|---|
ModelDefinitionError
|
if validation of related_names fail |
Source code in ormar\models\helpers\related_names_validation.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|