i have a task to sending mail take the time in database in celery but when it work it send all to user in all time but not one user in their time , (example : A has sent to 8:30 and b has send to 9:30) but when it work it send both to A and B in 8:30 , A and B in 9:30 , how can i fix that ?
@shared_task
def send_email_spetime():
top_article = Article.objects.all()[0]
article1 = Article.objects.all()[1:3]
article2 = Article.objects.all()[3:5]
last_article = Article.objects.all()[5:8]
context = {
'top_article': top_article,
'article1': article1,
'article2': article2,
'last_article': last_article,
}
#Sending the email to UserMail
# Sending the Email
users_mail = UserMail.objects.all()
for each_user in users_mail:
if each_user.auto_send_mail == False:
msg_plain = render_to_string('timeset/email_templates.txt')
msg_html = render_to_string('timeset/index3.html', context)
subject = "NEWS"
recepient = each_user.user_mail
send_mail(subject, msg_plain, EMAIL_HOST_USER, [recepient], html_message=msg_html, fail_silently=False)
send_email_spetime.apply_async(eta=each_user.time_set + timedelta(minutes=1))