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)

I have the same problem.

class FirmaKategori(models.Model):
    kategori = models.CharField(max_length=250)
    description = models.CharField(max_length=5000)
    slug = models.SlugField(max_length=250, null=False, unique=True, allow_unicode=True)

    def __str__(self):
        return self.kategori   
  
    def get_absolute_url(self):
        return reverse('firma-kategori-ekle')  

    def save(self, *args, **kwargs):
        self.slug = slugify(self.kategori, allow_unicode=False)
        super().save(*args, **kwargs)

I made this, and if i allow_unicode=True, Forexample i made a category its name is Takım Tezgahları, became takım-tezgahları, but i want takim-tezgahlari…

And i looked @toppylawz code but i didnt understand, i am new on django. But i wanna solve this problem.