moneropro/users/models.py
2022-06-30 10:43:56 -03:00

24 lines
No EOL
727 B
Python

from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver
class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
email = models.EmailField(max_length=150)
type = models.CharField(max_length=100, blank=True)
def __str__(self):
return self.user.username
class BlockedEmail(models.Model):
email = models.EmailField(max_length=150)
def __str__(self):
return self.id
@receiver(post_save, sender=User)
def update_profile_signal(sender, instance, created, **kwargs):
if created:
Profile.objects.create(user=instance)
instance.profile.save()