modern-django-starter/apps/accounts/signals.py
Django Template 4bbc56a08f Initial commit: Django boilerplate with authentication, Docker, and Dokploy support
 Features:
- Complete Django project with authentication
- Email/password and social login (Google, Facebook)
- Role-based access control (admin, staff, user)
- Docker and Docker Compose setup
- Production-ready configuration
- Static file handling with WhiteNoise
- PostgreSQL database integration
- Comprehensive documentation
- GitHub CI/CD workflows
- Dokploy deployment configuration

🚀 Ready for deployment on Dokploy, Heroku, Railway, and other platforms
2025-09-11 09:36:55 +05:30

19 lines
606 B
Python

from django.db.models.signals import post_save
from django.dispatch import receiver
from django.contrib.auth.models import Group
from .models import User, UserProfile
@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
if created:
UserProfile.objects.create(user=instance)
default_group, _ = Group.objects.get_or_create(name='user')
instance.groups.add(default_group)
@receiver(post_save, sender=User)
def save_user_profile(sender, instance, **kwargs):
if hasattr(instance, 'profile'):
instance.profile.save()