Exemple #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 HttpResponseRedirect('/contact')
        else:
            form = ContactView()
            return render(request, "contact.html", {"form": form})

    else:
        form = ContactView()
        return render(request, 'contact.html', {'form': form})
Exemple #2
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. Thanks a lot, I'll get back to you as soon as possible.")
            return HttpResponseRedirect('/contact')
        else:
            #form = ContactView()
            #messages.add_message(request, messages.ERROR, 'Your message not sent. Not enough data')
            return render(request, 'contact.html', {'form': form})

    else:
        form = ContactView()
        return render(request, 'contact.html', {'form': form})
Exemple #3
0
def contact(request):
    if request.method == 'POST':
        form = ContactView(request.POST)
        if form.is_valid():
            email = EmailMessage()
            email.from_email = form.cleaned_data.get('email')
            email.to = [request.POST.get('email')]
            email.topic = form.cleaned_data.get('topic')
            email.body = form.cleaned_data.get('message')

            data = EmailMessage()
            data.from_email = form.cleaned_data.get('email')
            data.to = ['*****@*****.**']
            data.topic = 'form received'
            data.body = 'message'

            my_form = form.save(commit=False)
            my_form.save()
            messages.add_message(request, messages.INFO, 'Your message has been sent. Thank you.')
            email.send()
            data.send()
            return HttpResponseRedirect('/')
    else:
        form = ContactView()

    return render(request, 'contact.html', {'form': form})
Exemple #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. Thanks a lot, I'll get back to you as soon as possible."
            )
            return HttpResponseRedirect('/contact')
        else:
            #form = ContactView()
            #messages.add_message(request, messages.ERROR, 'Your message not sent. Not enough data')
            return render(request, 'contact.html', {'form': form})

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