mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-07 01:58:11 +08:00
Example with f-string
This commit is contained in:
+2
-4
@@ -74,8 +74,7 @@ The task will send a message to everyone else informing them that the users emai
|
|||||||
def inform_everyone(user):
|
def inform_everyone(user):
|
||||||
mails = []
|
mails = []
|
||||||
for u in User.objects.exclude(pk=user.pk):
|
for u in User.objects.exclude(pk=user.pk):
|
||||||
msg = 'Dear {}, {} has a new email address: {}'
|
msg = f"Dear {u.username}, {user.username} has a new email address: {user.email}"
|
||||||
msg = msg.format(u.username, user.username, user.email)
|
|
||||||
mails.append(('New email', msg,
|
mails.append(('New email', msg,
|
||||||
'from@example.com', [u.email]))
|
'from@example.com', [u.email]))
|
||||||
return send_mass_mail(mails)
|
return send_mass_mail(mails)
|
||||||
@@ -85,8 +84,7 @@ The task will send a message to everyone else informing them that the users emai
|
|||||||
# or do it async again
|
# or do it async again
|
||||||
def inform_everyone_async(user):
|
def inform_everyone_async(user):
|
||||||
for u in User.objects.exclude(pk=user.pk):
|
for u in User.objects.exclude(pk=user.pk):
|
||||||
msg = 'Dear {}, {} has a new email address: {}'
|
msg = f"Dear {u.username}, {user.username} has a new email address: {user.email}"
|
||||||
msg = msg.format(u.username, user.username, user.email)
|
|
||||||
async_task('django.core.mail.send_mail',
|
async_task('django.core.mail.send_mail',
|
||||||
'New email', msg, 'from@example.com', [u.email])
|
'New email', msg, 'from@example.com', [u.email])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user