I have a form in index page and i have 12 inputs in forms , so if user submits the form i need all 12 inputs in body of my email . I tried different methods and tried searching on google and youtube but could not find the solution.
My urls.py:
from django.contrib import admin
from django.urls import path, include
from . import views
urlpatterns = [
path('', views.index,name='index'),
path('about/', views.about,name='about'),
path('contact/', views.contact,name='contact'),
]
my views.py:
from django.shortcuts import render
from django.http import HttpResponse
from django.core.mail import send_mail
def index(request):
if request.method == "POST":
year = request.POST['year']
make = request.POST['make']
part = request.POST['part']
engine = request.POST['engine']
transmission = request.POST['transmission']
name = request.POST['name']
email = request.POST['email']
phone = request.POST['phone']
state = request.POST['state']
zipcode = request.POST['zipcode']
address = request.POST['address']
form = "Year: " + year + "Make: " + make + "Part: " + part + "Engine: " + engine + "transmission: " + transmission + "Name: " + name + "Email: " + email + "Phone: " + phone + "State: " + state + "Zipcode: " + zipcode + "Address: " + address
send_mail(
'Mail from carparts',
form,
'arshadkhanak05@gmail.com.',
['arshadkhanak05@gmail.com'],
fail_silently=False,
)
return render(request, 'index.html')
def about(request):
return render(request, 'about.html')
def contact(request):
return render(request, 'contact.html')
help me solve this code
Thank you