mirror of
https://github.com/SectorLabs/django-localized-fields.git
synced 2025-04-25 03:32:55 +03:00
Fixed slugs not being generated for unicode texts
This commit is contained in:
parent
c01edc80f0
commit
fc31e1e5f1
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user