Add support for using a callable to populate slug with

This commit is contained in:
Swen Kooij
2017-06-26 13:03:32 +03:00
parent 8ad9268426
commit d7382fbf30
2 changed files with 35 additions and 9 deletions

View File

@@ -166,6 +166,9 @@ class LocalizedAutoSlugField(LocalizedField):
The text to generate a slug for.
"""
if callable(field_name):
return field_name(instance)
def get_field_value(name):
value = resolve_object_property(instance, name)
with translation.override(language):