-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsignals.py
20 lines (18 loc) · 898 Bytes
/
signals.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver
from .models import Profile
from .tasks import send_async_mail
@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
if created:
Profile.objects.create(user=instance, role=0,
name=instance.first_name+' '+instance.last_name)
send_async_mail.apply_async(
args=[
'Useful Python',
'Welcome to Useful Python! Learn about useful Python libraries and techniques to make your tasks more efficient and automated. You can also find many ready-to-use tools to make use of right away! You can contact us anytime through this email address.',
[instance.email]
]
)