亚欧大陆资源环境与经济社会发展本底数据管理

亚欧大陆资源环境与经济社会发展本底数据管理

注册    |    登陆

Django Wiki中Slug中文无法使用的问题解决

发布日期 :2025年7月3日 09:52      

分类 :其他

标签 :

访问量: 9 次浏览

If someone wants to have utf 8, in the url, do this.

Wiki/Models/urlpath.py On line 80: add "allow_unicode=True" slug = models.SlugField(allow_unicode=True, verbose_name=_('slug'), null=True, blank=True, max_length=SLUG_MAX_LENGTH)

Wiki/forms.py On line 317: add "allow_unicode=True" slug = forms.SlugField( allow_unicode=True, label=('Slug'), help_text=( "This will be the address where your article can be found. Use only alphanumeric characters and - or _. Note that you cannot change the slug after creating the article."), max_length=models.URLPath.SLUG_MAX_LENGTH)

Wiki/views/article.py On line 74: remove attrs={}

Remove: attrs={ # Make patterns force lowercase if we are case insensitive to bless the user with a # bit of strictness, anyways 'pattern': '[a-z0-9_-]+' if not settings.URL_CASE_SENSITIVE else '[a-zA-Z0-9_-]+', 'title': 'Lowercase letters, numbers, hyphens and underscores' if not settings.URL_CASE_SENSITIVE else 'Letters, numbers, hyphens and underscores', }

Solution For: Django 1.9=>