Issue
am trying to build an app with a model which contains a unique of the title, some users will write the title in Arabic and other languages and when on save, I try to slugify the field. It would return blank in case of Arabic. Any way to show arabic wordings but maintain slug principles of replacing special characters and spaces with dash?
class Article(models.Model):
title = models.CharField(max_length=100)
slug = models.SlugField()
def save(self, *args, **kwargs):
if self.slug is in (None, '', u''):
self.slug = slugify(self.title)
super(Article, self).save(*args, **kwargs)
Solution
To enable url encoder, simply open settings.py and at the end of file, insert as new line:
ALLOW_UNICODE_SLUGS = True
Answered By - iraj jelodari
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.