timbres email 2 production
This commit is contained in:
@@ -18,7 +18,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
|||||||
SECRET_KEY = 'django-insecure-5*mm&uf5zq@t6nrs_5z8-_qtyapm^3&yz^wqqkc_a!v(!ulj-^'
|
SECRET_KEY = 'django-insecure-5*mm&uf5zq@t6nrs_5z8-_qtyapm^3&yz^wqqkc_a!v(!ulj-^'
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = False
|
DEBUG = True
|
||||||
|
|
||||||
ALLOWED_HOSTS = ['*']
|
ALLOWED_HOSTS = ['*']
|
||||||
|
|
||||||
|
|||||||
@@ -74,18 +74,24 @@ def send_timbres_Email(request):
|
|||||||
ws['A' + str(q)] = qq.RFC
|
ws['A' + str(q)] = qq.RFC
|
||||||
ws['B'+ str(q)] = qq.Nombre
|
ws['B'+ str(q)] = qq.Nombre
|
||||||
ws['C'+ str(q)] = qq.conteo_mes
|
ws['C'+ str(q)] = qq.conteo_mes
|
||||||
excel = BytesIO()
|
|
||||||
|
nombre_archivo = f"Timbres_{RFC if RFC is not None else 'Clientes_MES'}_{str(mes)}_AÑO_{str(year)}.xlsx"
|
||||||
|
response = HttpResponse(content_type="application/ms-excel")
|
||||||
|
contenido = "attachment; filename = {0}".format(nombre_archivo)
|
||||||
|
response["Content-Disposition"] = contenido
|
||||||
|
wb.save(response)
|
||||||
|
|
||||||
|
files = BytesIO(response.content)
|
||||||
|
|
||||||
|
#print('files: ',response.content)
|
||||||
|
|
||||||
nombre_archivo = f"Timbres_{RFC if RFC is not None else 'Clientes_MES'}_{str(mes)}_AÑO_{str(year)}.xls"
|
|
||||||
wb.save(excel)
|
|
||||||
print('excel: ',excel)
|
|
||||||
Cli = Clientes.objects.get(RFC=RFC)
|
Cli = Clientes.objects.get(RFC=RFC)
|
||||||
subject = f'Timbres del Mes:{mes} RFC:{RFC}'
|
subject = f'Timbres del Mes:{mes} RFC:{RFC}'
|
||||||
message = 'Envio de timbres por AS_Admin'
|
message = 'Envio de timbres por AS_Admin'
|
||||||
email = Cli.email
|
email = Cli.email
|
||||||
try:
|
try:
|
||||||
mail = EmailMessage(subject,message,settings.EMAIL_HOST_USER,[email])
|
mail = EmailMessage(subject,message,settings.EMAIL_HOST_USER,[email])
|
||||||
mail.attach(filename='Timbres.xls',content=excel.getbuffer(),mimetype='application/vnd.ms-excel')
|
mail.attach(filename='Timbres.xls',content=files.getbuffer(),mimetype='application/vnd.ms-excel')
|
||||||
mail.send()
|
mail.send()
|
||||||
print('SE armo')
|
print('SE armo')
|
||||||
except:
|
except:
|
||||||
|
|||||||
Reference in New Issue
Block a user