Answer the question
In order to leave comments, you need to log in
How to transliterate urls in django?
Is it possible to make the database field be in Russian, and the link to it be transliterated into English.
deck_name = 'физика'
url = 'app/fizika'
class Deck(models.Model):
name = models.CharField(max_length = 30)
name_eng = models.CharField(max_length=30, default=name.upper())
[\w-]
, and not just \w
, because in slug spaces are replaced by'-'
Answer the question
In order to leave comments, you need to log in
This is called slug (or CNC, if in Russian). Unfortunately, the jungian slugify function does not understand Cyrillic, so for one of my projects I wrote a wrapper for Cyrillic. You can see it here: https://gist.github.com/deliro/01851103f7a0206fe66d
class Deck(models.Model):
slug = models.SlugField()
name = models.CharField(max_length=30)
def save(self, *args, **kwargs):
self.slug = slugify(self.name)
super().save(*args, **kwargs)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question