Django Slugify Error

Hello guys when i tried to slug an word at template something does not work propreatly. Here is my code:
“Taşıma Ekipmanları”|slugify
and result of this code must be this = “tasima-ekipmanlari” but i get “tasma-ekipmanlar” and my django version is 3.1.4. I hope someone can help me
And plus i used to use slugify at my models and this problem was still exist at models too. But i didn’t saw that as a big problem.

Are you using autoslug? https://pypi.org/project/django-autoslug/ I have had success with it.

No i don’t think i’m using this. I’m using models.SlugField. But thx for suggestion if i couldn’t solve problem i’ll install django-autoslug.

I checked out the slugify function in django-autoslug - same thing happens.

I know just enough about Unicode to know that lower-case i with dot is a different character than lower-case i without dot, and that the two are not the same.

From the slugify function docs, it does say that any characters that don’t map to ascii characters are removed. This appears to be the case here - there is no ascii mapping for the lower-case i without dot, and so it’s dropped.

I don’t believe there is a valid work-around for this without doing your own character substitution on the string before using slugify.

2 Likes

Since you are using models you can write this small function after the importing the proper library:

from django.utils.text import slugify

def save(self, *args, **kwargs):

        if not self.WhatYouWantToSlug and self.WhereYouWantToGeytSlugFrom:

            self.WhatYouWantToSlug= slugify(self.WhereYouWantToGeytSlugFrom)

        super(NameOfClass, self).save(*args, **kwargs)