Exemplo n.º 1
0
def Message(request):
    if request.method == 'POST':
        name = request.POST['name']
        email = request.POST['email']
        message = request.POST['message']

        #Saving Message form Contact Us
        contact = Contact()
        contact.name = name
        contact.email = email
        contact.message = message

        contact.save()

        messages.success(request, "Your Message is Delivered Successfully")
        #Redirecting To Home Page
        return redirect('Home')
Exemplo n.º 2
0
def contact_form(request):
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            contactdata = Contact()
            contactdata.name = form.cleaned_data['name']
            contactdata.email = form.cleaned_data['email']
            contactdata.subject = form.cleaned_data['subject']
            contactdata.message = form.cleaned_data['message']
            contactdata.save()

            messages.success(
                request,
                "Your message has been sent. Thank you for you interest ")
            return HttpResponseRedirect('/contact')
    else:
        form = ContactForm()

        return render(request, 'contact.html', {'form': form})
Exemplo n.º 3
0
def contact_form(request):
    # if this is a POST request we need to process the form data
    if request.method == 'POST':
        # create a form instance and populate it with data from the request:
        form = ContactForm(request.POST)
        # check whether it's valid:
        if form.is_valid():

            contactdata=Contact()
            contactdata.name =  form.cleaned_data['name']
            contactdata.email = form.cleaned_data['email']
            contactdata.subject = form.cleaned_data['subject']
            contactdata.message = form.cleaned_data['message']
            contactdata.save()

            messages.success(request, "Your message has been sent. Thank You for your interest ")
            return HttpResponseRedirect('/contact')
    else:
        form = ContactForm()
    return render(request, 'contact.html', {'form': form})
Exemplo n.º 4
0
def contact_form(request):
    categoryList = Category.objects.all()
    if request.method == "POST":
        form = ContactForm(request.POST)
        if form.is_valid():
            contactdata = Contact()
            contactdata.name = form.cleaned_data['name']
            contactdata.email = form.cleaned_data['email']
            contactdata.subject = form.cleaned_data['subject']
            contactdata.message = form.cleaned_data['message']
            contactdata.save()

            messages.success(request, "Your message has been sent.")
            return HttpResponseRedirect('/contact')
    else:
        form = ContactForm()

    context = {
        'form': form,
        'categoryList': categoryList,
    }
    return render(request, 'contact.html', context)