Files
guilan-ace-backend/apps/users/signals.py
Amirhossein Khalili b7b21a6cc6
Some checks failed
Backend CI/CD / test (push) Has been cancelled
Backend CI/CD / deploy (push) Has been cancelled
feat(backend): migrate auth and notifications off email
2026-05-21 10:28:04 +03:30

14 lines
386 B
Python

import uuid
from django.db.models.signals import post_save
from django.dispatch import receiver
from apps.users.models import User
@receiver(post_save, sender=User)
def ensure_username_on_registration(sender, instance, created, **kwargs):
if created and not instance.username:
instance.username = str(uuid.uuid4())[:10]
instance.save(update_fields=["username"])