Exemplo n.º 1
0
def contact(request):
    if request.method == 'POST':
        form = ContactView(request.POST)
        if form.is_valid():
            my_form = form.save(commit=False)
            my_form.save()
            messages.add_message(request, messages.SUCCESS, 'Your message has been sent. Thank you.')
            return render(request, 'index.html')
    else:
        form = ContactView()
    return render(request, 'contact.html', {'form': form})
Exemplo n.º 2
0
def contact(request):
    if request.method == 'POST':
        form = ContactView(request.POST)
        if form.is_valid():
            email = EmailMessage(subject=request.POST.get('topic'), body=request.POST.get('message'),
                                 from_email="*****@*****.**", to=[request.POST.get('email')])
            email.send()
            my_form = form.save(commit=False)
            my_form.save()
            messages.add_message(request, messages.INFO, 'Your message has been set. Thank You')

            return redirect("/")

    else:
        form = ContactView()
    return render(request, 'contact.html', {'form': form})
Exemplo n.º 3
0
def contact(request):
    if request.method == 'POST':
        form = ContactView(request.POST)

        if form.is_valid():
            email = EmailMessage(subject=request.POST.get('topic'), body=request.POST.get('message'),
                                 from_email=request.POST.get('email'), to=["*****@*****.**"])
            # email.send()
            send_mail('Hey', 'This is my message', '*****@*****.**', ['*****@*****.**'], fail_silently=False)
            my_form = form.save(commit=False)
            my_form.save()
            messages.add_message(request, messages.INFO, 'Your message has been set. Thank You')

            return redirect("/")

    else:
        form = ContactView()
    return render(request, 'contact.html', {'form': form})
Exemplo n.º 4
0
def contact(request):
    if request.method == 'POST':
        form = ContactView(request.POST)
        if form.is_valid():
            my_form = form.save(commit=False)
            my_form.save()
            messages.add_message(request, messages.SUCCESS,
                                 'Your message has been sent. Thank you. ')
            return render(request, 'index.html')
    else:
        form = ContactView()
    return render(request, 'contact.html', {'form': form})
Exemplo n.º 5
0
def contact(request):
    if request.method == 'POST':
        form = ContactView(request.POST)
        if form.is_valid():
            email = EmailMessage(subject=request.POST.get('topic'),
                                 body=request.POST.get('message'),
                                 from_email="*****@*****.**",
                                 to=[request.POST.get('email')])
            email.send()
            my_form = form.save(commit=False)
            my_form.save()
            messages.add_message(request, messages.INFO,
                                 'Your message has been set. Thank You')

            return redirect("/")

    else:
        form = ContactView()
    return render(request, 'contact.html', {'form': form})