Model helpers
django_rubble.utils.model_helpers
get_model_fields(model, *, fields=None, exclude=None)
Returns list of fields from model.
Cannot include both fields and exclude.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
type[Model]
|
the model to get fields from |
required |
fields |
list[str] | None
|
list of fields to include, default is None |
None
|
exclude |
list[str] | None
|
list of fields to exclude, default is None |
None
|
Returns:
Type | Description |
---|---|
list[Field]
|
list of fields |
Source code in django_rubble\utils\model_helpers.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
get_model_label(model)
Get model's label as defined in Meta class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
Model
|
the model to get label from |
required |
Returns:
Type | Description |
---|---|
str
|
model's label |
Source code in django_rubble\utils\model_helpers.py
33 34 35 36 37 38 39 40 41 |
|
get_model_name(model)
Get model's name as defined in Meta class.
Will return as all lower case
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
type[Model]
|
the model to get name from |
required |
Returns:
Type | Description |
---|---|
str
|
model's name |
Source code in django_rubble\utils\model_helpers.py
7 8 9 10 11 12 13 14 15 16 17 18 |
|
get_model_verbose_name_plural(model)
Get model's verbose name as defined in Meta class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
type[Model]
|
the model to get verbose name from |
required |
Returns:
Type | Description |
---|---|
str
|
model's verbose name |
Source code in django_rubble\utils\model_helpers.py
21 22 23 24 25 26 27 28 29 30 |
|