https://github.com/ceol/django-autoslug 如果我不想要unicode字符,如何编辑它?只是没有外语字符的字母和数字。
我确信我需要编辑这部分代码,但我不知道如何编写代码。它是:https://github.com/ceol/django-autoslug/blob/master/autoslug/utils.py
的一部分 a URL with these characters included would confuse users and
# machines alike, so it's best to replace them; however, we
# still want Unicode characters in foreign languages to appear
pattern = r'[^\s\/\?\-\.\[\]\$\+\^\'"_~:#@!&()*,;=%]+'
答案 0 :(得分:0)
也许是这样的:
slug = AutoSlugField(populate_from=lambda instance: instance.title.encode('ascii', errors='ignore')
答案 1 :(得分:0)
我将ceol的autoslug更改为:https://pypi.python.org/pypi/django-autoslug - 仅使用ascii字符创建slug。