diff --git a/localized_fields/fields/localized_autoslug_field.py b/localized_fields/fields/localized_autoslug_field.py index 4b20ff6..7476f70 100644 --- a/localized_fields/fields/localized_autoslug_field.py +++ b/localized_fields/fields/localized_autoslug_field.py @@ -83,7 +83,12 @@ class LocalizedAutoSlugField(LocalizedField): return not type(instance).objects.filter(**unique_filter).exists() - slug = self._make_unique_slug(slugify(value), lang_code, is_unique) + slug = self._make_unique_slug( + slugify(value, allow_unicode=True), + lang_code, + is_unique + ) + slugs.set(lang_code, slug) setattr(instance, self.name, slugs) diff --git a/tests/test_localized_auto_slug_field.py b/tests/test_localized_auto_slug_field.py index 65176d4..d1de675 100644 --- a/tests/test_localized_auto_slug_field.py +++ b/tests/test_localized_auto_slug_field.py @@ -59,6 +59,17 @@ class LocalizedAutoSlugFieldTestCase(TestCase): assert another_obj.slug.en == 'title-1' + def test_unique_slug_utf(self): + """Tests whether generating a slug works + when the value consists completely out + of non-ASCII characters.""" + + obj = self.TestModel() + obj.title.en = 'مكاتب للايجار بشارع بورسعيد' + obj.save() + + assert obj.slug.en == 'مكاتب-للايجار-بشارع-بورسعيد' + @staticmethod def test_deconstruct(): """Tests whether the :see:deconstruct