Django:AutoSlug 错误 "slug is defined before trying to ensure uniqueness"
Django: AutoSlug error "slug is defined before trying to ensure uniqueness"
我有一个带有 django-autoslug
字段的模型:
class Article(models.Model):
headline = models.TextField()
content = models.TextField()
slug = AutoSlugField(populate_from='headline', max_length=128, allow_unicode=True, always_update=True)
在开发环境 (OS X + Postgres) 中一切正常。但是,在已部署的实例 (Ubuntu + Postgres) 上,尝试使用 django admin 创建 object 时会发生错误。仅当标题中包含西里尔文时才会出现:
AssertionError: slug is defined before trying to ensure uniqueness
django-autoslug
使用 Unidecode
,但 django-autoslug
没有将其作为依赖项安装。它用于对 unicode 文本进行 slugify。它有时已经安装到我的开发机器上的虚拟环境中,但是服务器的环境缺少它。只需安装它:
pip3 install Unidecode==0.4.19
我有一个带有 django-autoslug
字段的模型:
class Article(models.Model):
headline = models.TextField()
content = models.TextField()
slug = AutoSlugField(populate_from='headline', max_length=128, allow_unicode=True, always_update=True)
在开发环境 (OS X + Postgres) 中一切正常。但是,在已部署的实例 (Ubuntu + Postgres) 上,尝试使用 django admin 创建 object 时会发生错误。仅当标题中包含西里尔文时才会出现:
AssertionError: slug is defined before trying to ensure uniqueness
django-autoslug
使用 Unidecode
,但 django-autoslug
没有将其作为依赖项安装。它用于对 unicode 文本进行 slugify。它有时已经安装到我的开发机器上的虚拟环境中,但是服务器的环境缺少它。只需安装它:
pip3 install Unidecode==0.4.19