From e6ffb476fbefa4df922af4862c0bf7ac4a443d34 Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Sat, 21 Jun 2025 23:07:36 +0300 Subject: [PATCH] Features: 1) Update regex pattern for slug field generation to exclude non-alphanumeric characters; 2) Add support for custom separators in slugs; Fixes: 1) Remove unnecessary debug logging from get_slug_fields function; Extra: 1) Minor cleanup in db utility functions; --- core/utils/db.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/core/utils/db.py b/core/utils/db.py index c4b61c86..07c5ee30 100644 --- a/core/utils/db.py +++ b/core/utils/db.py @@ -26,7 +26,8 @@ def unicode_slugify_function(content): max_length=88, word_boundary=True, save_order=True, - regex_pattern=r"/", + regex_pattern=r"[^A-Za-z0-9-]+", + separator="-", ) @@ -38,10 +39,6 @@ class TweakedAutoSlugField(AutoSlugField): lookup_value_path = lookup_value.split(LOOKUP_SEP) attr = model_instance - logger.debug( - f"get_slug_fields: lookup_value_path is {lookup_value_path} and attr is {attr}" - ) - for elem in lookup_value_path: try: attr = getattr(attr, elem)