예제 #1
0
def contactos(request):
    if request.method == 'POST':
        form=FormularioContactos(request.POST)
        if form.is_valid():
            cd=form.cleaned_data
            send_mail(cd['asunto'],cd['mensaje'],cd.get('email','*****@*****.**'),['*****@*****.**'],)
            return HttpResponseDirect('contactos/gracias')
    else:
        form=FormularioContactos(initial={'asunto':'Adoro tu sitio'})
    return render(request,'formulariocontactos.html',{'form':form})
예제 #2
0
def contactos(request):
    if request.method == 'POST':
        form = FormularioContactos(request.POST) 
        if form.is_valid():
            cd = form.cleaned_data 
            send_mail(cd['asunto'],cd['mensaje'],'*****@*****.**',[cd['email']],fail_silently=False)
            return HttpResponseRedirect('/contactos/gracias/') 
    else:
        form = FormularioContactos()
    return render(request,'formulario_contactos.html', {'form': form})
예제 #3
0
def contactos(request):

    if request.method=='POST':
        form=FormularioContactos(request.POST)
        if form.is_valid():
            cd=form.cleaned_data
            send_mail(request.POST['asunto'], request.POST['mensaje'],
                      request.POST.get('email','*****@*****.**'),
                      ['*****@*****.**'])
            return HttpResponseRedirect('/contactos/')
    else:
        form=FormularioContactos()
    return render(request, 'forulario-contactos.html', {'form':form})
예제 #4
0
def contactos(request):
    if request.method == 'POST':
        form = FormularioContactos(request.POST)
        if form.is_valid():
            cd = form.cleaned_data
            send_mail(
                cd['asunto'],
                cd['mensaje'],
                cd.get('email', '*****@*****.**'),
                ['*****@*****.**'],
            )
            return HttpResponseRedirect('/contactos/gracias/')
    else:
        form = FormularioContactos(initial={'asunto': 'Adoro tu sitio!'})
    return render(request, 'formulario-contactos.html', {'form': form})
예제 #5
0
def contactos(request):
    if request.method == 'POST':
        form = FormularioContactos(request.POST)
        if form.is_valid():
            cd = form.cleaned_data
            mail = EmailMessage(
                cd['asunto'],
                cd['mensaje'],
                cd.get('email', '*****@*****.**'),
                ['*****@*****.**'],#direccion adonde llega
            )
            mail.send()
            return HttpResponseRedirect('/contactos/gracias/')
    else:
        form = FormularioContactos()
    return render(request, 'formulario-contactos.html', {'form': form})
예제 #6
0
def contactos(request):
	if request.method == 'POST':
		form = FormularioContactos(request.POST)
		if form.is_valid():
			cd = form.cleaned_data
			send_mail(cd['asunto'],cd['mensaje'],cd.get('email',
				'*****@*****.**'),['*****@*****.**'])
			return render_to_response('gracias.html',{'mensaje':cd.get('mensaje'), 
				'asunto':cd.get('asunto'),'email':cd.get('email')})
	else:
		form = FormularioContactos(initial={'asunto':"que buen sitio!",
			'email':"*****@*****.**",'mensaje':"sarasaaaaaaaaaaa"})
	return render(request,'formulario-contactos.html',{'form':form})

	# Personalizacion de validaciones
	def clean_mensaje(self):
		mensaje = self.cleaned_data['mensaje']
		num_palabras = len(mensaje.split())
		if num_palabras < 4:
			raise forms.ValidationError("Se requieren minimo 4 palabras!")
		return mensaje