From 3e97f8424d4c336da97e380dea705af07706809b Mon Sep 17 00:00:00 2001 From: Amaury Carrade Date: Sat, 17 Apr 2021 16:43:13 +0200 Subject: [PATCH] We still generate short slugs --- hawk/settings/base.py | 4 ++++ hawk_gui/models.py | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hawk/settings/base.py b/hawk/settings/base.py index 86dcac7..65f0f46 100644 --- a/hawk/settings/base.py +++ b/hawk/settings/base.py @@ -103,3 +103,7 @@ MAINTENANCE_MODE_STATE_FILE_PATH = "maintenance" MAINTENANCE_MODE_RETRY_AFTER = 60 # one minute + +HAWK = { + "SLUG_LENGTH": 8 +} diff --git a/hawk_gui/models.py b/hawk_gui/models.py index f27634b..9c13d59 100644 --- a/hawk_gui/models.py +++ b/hawk_gui/models.py @@ -1,6 +1,7 @@ import random - import string + +from django.conf import settings from django.db import models from django.urls import reverse_lazy from django.utils.html import format_html @@ -140,7 +141,7 @@ def save(self, **kwargs): slug = "".join( random.choices( string.ascii_lowercase + string.digits, - k=self._meta.get_field("slug").max_length, + k=settings.HAWK['SLUG_LENGTH'], ) ) # We said unique slug