added slug index

This commit is contained in:
Alexander Karpov 2023-07-04 14:09:01 +03:00
parent e3454a142a
commit 98e9a4e036

View File

@ -65,7 +65,7 @@ class SlugModel(models.Model):
for custom slug length use: slug_length, private_slug_length Meta options
"""
slug = models.SlugField(max_length=20, blank=True, unique=True)
slug = models.SlugField(max_length=20, blank=True, unique=True, db_index=True)
@classmethod
def __init_subclass__(cls, **kwargs):
@ -73,6 +73,7 @@ def __init_subclass__(cls, **kwargs):
models.signals.pre_save.connect(create_model_slug, sender=cls)
class Meta:
indexes = ["slug"]
abstract = True
class SlugMeta: