diff --git a/apps/establishment/models.py b/apps/establishment/models.py index 5cfa3349..086dd783 100644 --- a/apps/establishment/models.py +++ b/apps/establishment/models.py @@ -3,6 +3,7 @@ from datetime import datetime from functools import reduce from operator import or_ from typing import List +from slugify import slugify import elasticsearch_dsl from django.conf import settings @@ -655,6 +656,14 @@ class Establishment(GalleryMixin, ProjectBaseMixin, URLImageMixin, def __str__(self): return f'id:{self.id}-{self.name}' + def save(self, *args, **kwargs): + slugify_slug = slugify( + self.index_name, + word_boundary=True + ) + self.slug = slugify_slug + super(Establishment, self).save(*args, **kwargs) + def delete(self, using=None, keep_parents=False): """Overridden delete method""" # TODO: If this does not contradict the plan,