ed: contacto() para uso deAPI forms
This commit is contained in:
parent
75325d5894
commit
14821bbdfc
@ -3,6 +3,7 @@ from django.http import HttpResponse
|
|||||||
from gestionPedidos.models import Articulos
|
from gestionPedidos.models import Articulos
|
||||||
from django.core.mail import send_mail
|
from django.core.mail import send_mail
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from gestionPedidos.forms import FormContacto
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
def busqueda_productos(request):
|
def busqueda_productos(request):
|
||||||
@ -22,13 +23,27 @@ def buscar(request):
|
|||||||
return HttpResponse(msj)
|
return HttpResponse(msj)
|
||||||
|
|
||||||
|
|
||||||
|
# def contacto(request):
|
||||||
|
# if request.method == "POST":
|
||||||
|
# subject = request.POST['asunto']
|
||||||
|
# message = request.POST['mensaje']+' '+request.POST['mail']
|
||||||
|
# email_from = settings.EMAIL_HOST_USER
|
||||||
|
# recipient_list = ['ratablastard@gmail.com']
|
||||||
|
# send_mail(subject, message, email_from, recipient_list)
|
||||||
|
# return render(request, "gracias.html")
|
||||||
|
# return render(request, "contacto.html")
|
||||||
|
|
||||||
def contacto(request):
|
def contacto(request):
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
subject = request.POST['asunto']
|
miForm = FormContacto(request.POST)
|
||||||
message = request.POST['mensaje']+' '+request.POST['mail']
|
if miForm.is_valid():
|
||||||
email_from = settings.EMAIL_HOST_USER
|
contenido = miForm.cleaned_data
|
||||||
recipient_list = ['ratablastard@gmail.com']
|
|
||||||
send_mail(subject, message, email_from, recipient_list)
|
|
||||||
return render(request, "gracias.html")
|
|
||||||
return render(request, "contacto.html")
|
|
||||||
|
|
||||||
|
send_mail(contenido['asunto'], contenido['msj'],
|
||||||
|
contenido.get('email',''),['ratablastard@gmail.com'],)
|
||||||
|
|
||||||
|
return render(request, 'gracias.html')
|
||||||
|
else:
|
||||||
|
miForm = FormContacto()
|
||||||
|
|
||||||
|
return render(request, 'form_contacto.html', {"form":miForm})
|
Loading…
Reference in New Issue
Block a user