Skip to content

Instantly share code, notes, and snippets.

View lopinho's full-sized avatar
🏠
Working from home

Andre Lopes lopinho

🏠
Working from home
  • Rio de Janeiro, RJ
View GitHub Profile
from usuarios.models import *
from django.conf import settings
from django.core.mail import EmailMessage
estado = 'BA'
destinatarios = ['[email protected]', '[email protected]']
emails = User.objects.filter(userprofile__localidade__estado__sigla=estado, userprofile__ativo_para_o_site=True).values_list('email', flat=True)
message = EmailMessage('Emails do estado %s' % estado, 'em anexo', settings.EMAIL_HOST_USER, destinatarios)