mirror of
https://github.com/leaders-of-digital-9-task/backend.git
synced 2024-11-15 05:56:34 +03:00
13 lines
383 B
Python
13 lines
383 B
Python
from dicom.models import Dicom
|
|
from django.db.models.signals import pre_save
|
|
from django.dispatch import receiver
|
|
from utils.generators import generate_charset
|
|
|
|
|
|
@receiver(pre_save, sender=Dicom)
|
|
def create_dicom(sender, instance: Dicom, **kwargs):
|
|
slug = generate_charset(5)
|
|
while Dicom.objects.filter(slug=slug):
|
|
slug = generate_charset(5)
|
|
instance.slug = slug
|