5π
β
To enable url encoder, simply open settings.py and at the end of file, insert as new line:
ALLOW_UNICODE_SLUGS = True
π€iraj jelodari
4π
def save(self, *args, **kwargs):
if not self.slug:
self.slug = slugify(self.title)
if not self.slug:
self.slug = arabic_slugify(self.title)
super(Note, self).save(*args, **kwargs)
def __str__(self):
return self.title
def arabic_slugify(str):
str = str.replace(" ", "-")
str = str.replace(",", "-")
str = str.replace("(", "-")
str = str.replace(")", "")
str = str.replace("Ψ", "")
return str
π€user10157392
- [Django]-Django can't process non-ascii symbols
- [Django]-Running Gunicorn behind chrooted nginx inside virtualenv
- [Django]-Receiving error: django.core.exceptions.ImproperlyConfigured
3π
New to Django 1.9 is the setting allow_unicode
:
slug = SlugField(allow_unicode=True)
π€Flimm
1π
It is better to use
allow_unicode=True
attr for each SlugField
that you want to make it allowing Unicode.
This is s simple example:
slug = models.SlugField(max_length=200, allow_unicode=True, unique=True)
For the new versions of Django
the settings.py
ALLOW_UNICODE_SLUGS = True
attribute will not work.
0π
check this https://github.com/mozilla/unicode-slugify , I have use it with Django 1.4.x/1.5.x, I was also looking for Arabic slugs.
π€Mustafa
- [Django]-Deleting periodic task for celery scheduler in `settings.py` will not delete the actual task
- [Django]-Django admin with websocket
Source:stackexchange.com