misc: account for slug default max length of 50 characters (#30855)

This commit is contained in:
Frédéric Péters 2019-08-13 08:16:27 +02:00
parent c289591dd3
commit eacd1a51f5
2 changed files with 2 additions and 2 deletions

View File

@ -16,7 +16,7 @@ class Migration(migrations.Migration):
new_slugs = {}
for instance in Visualization.objects.all():
if not instance.slug:
new_slug = slugify(instance.name[:60]).strip('-')
new_slug = slugify(instance.name[:40]).strip('-')
if new_slug in new_slugs:
i = 2
while True:

View File

@ -51,7 +51,7 @@ class Visualization(models.Model):
def save(self, *args, **kwargs):
if not self.slug:
slug = base_slug = slugify(self.name)[:60].strip('-')
slug = base_slug = slugify(self.name)[:40].strip('-')
i = 1
while True:
try: