mirror of
https://github.com/SectorLabs/django-localized-fields.git
synced 2025-12-14 07:42:24 +03:00
Support for slugging from multiple fields
This commit is contained in:
@@ -19,3 +19,26 @@ def get_language_codes() -> List[str]:
|
||||
lang_code
|
||||
for lang_code, _ in settings.LANGUAGES
|
||||
]
|
||||
|
||||
|
||||
def resolve_object_property(obj, path: str):
|
||||
"""Resolves the value of a property on an object.
|
||||
|
||||
Is able to resolve nested properties. For example,
|
||||
a path can be specified:
|
||||
|
||||
'other.beer.name'
|
||||
|
||||
Raises:
|
||||
AttributeError:
|
||||
In case the property could not be resolved.
|
||||
|
||||
Returns:
|
||||
The value of the specified property.
|
||||
"""
|
||||
|
||||
value = obj
|
||||
for path_part in path.split('.'):
|
||||
value = getattr(value, path_part)
|
||||
|
||||
return value
|
||||
|
||||
Reference in New Issue
Block a user