【发布时间】:2021-04-21 08:04:14
【问题描述】:
I am new in django .. i have to created three id in that userid same but emailid should be diffrent i want i am sending three emaild it showing me one email id 3 times i am not understanding to store different different email id in id 1, id 2, id 3, but user name is same please help me how to save i amnot understanding in view.py i am add for loop relation database but its taking same mail id please help me how to do i amnot undestanding please................
我是 django 的新手 .. 我必须在该用户 ID 中创建三个相同的 ID,但电子邮件 ID 应该不同在 id 1、id 2、id 3 中,但用户名相同请帮助我如何保存我在 view.py 中不理解我添加了循环关系数据库但它采用相同的邮件 id 请帮助我怎么做我不明白请。
# views.py
def trade_references(request):
#print('trade_reference', request.session.get('email'))
if request.method == 'POST' and request.session.has_key('email'):
print('trade_reference',request.session.get('email'))
# arg1 = MyCompanyData.objects.filter(email=request.session.get('email')).last()
#print('dfagda',arg1)
Company_name = request.POST['Company_name']
Company_name1 = request.POST['Company_name1']
Company_name2 = request.POST['Company_name2']
Contact_name = request.POST['Contact_name']
Contact_name1 = request.POST['Contact_name1']
Contact_name2 = request.POST['Contact_name2']
Contact_Email = request.POST['Contact_Email']
Contact_Email1 = request.POST['Contact_Email1']
Contact_Email2 = request.POST['Contact_Email2']
Address = request.POST['Address']
Address1 = request.POST['Address1']
Address2 = request.POST['Address2']
phone = request.POST['phone']
phone1 = request.POST['phone1']
phone2 = request.POST['phone2']
Length_of_relation = request.POST['Length_of_relation']
Length_of_relation1 = request.POST['Length_of_relation1']
Length_of_relation2 = request.POST['Length_of_relation2']
Credit_limit = request.POST['Credit_limit']
Credit_limit1 = request.POST['Credit_limit1']
Credit_limit2 = request.POST['Credit_limit2']
Average_Month = request.POST['Average_Month']
Average_Month1 = request.POST['Average_Month1']
Average_Month2 = request.POST['Average_Month2']
data = TradeInformation(Company_name = Company_name, Company_name1 = Company_name1, Company_name2 = Company_name2,
Contact_name = Contact_name, Contact_name1 = Contact_name1, Contact_name2 = Contact_name2,
Contact_Email = Contact_Email,Contact_Email1 = Contact_Email1, Contact_Email2 = Contact_Email2,
Address = Address, Address1 = Address1, Address2 = Address2, phone = phone, phone1 = phone1,
phone2 = phone2, Length_of_relation = Length_of_relation, Length_of_relation1 =Length_of_relation1,
Length_of_relation2 = Length_of_relation2, Credit_limit = Credit_limit, Credit_limit1 = Credit_limit1,
Credit_limit2 = Credit_limit2, Average_Month = Average_Month, Average_Month1= Average_Month1,
Average_Month2= Average_Month2)
data.save()
for i in range(0,3):
email = request.session.get('email')
Contact_Email = request.POST['Contact_Email']
Contact_Email1 = request.POST['Contact_Email1']
Contact_Email2 = request.POST['Contact_Email2']
related = Relationtable(userId=email,ContactEmailID=Contact_Email[i])
related.save()
subject = 'Email - Testing'
html_content = render_to_string('Email_id.html')
text_content = strip_tags(html_content)
msg = EmailMultiAlternatives(subject, text_content,settings.EMAIL_HOST_USER, to=[Contact_Email, Contact_Email1, Contact_Email2])
msg.attach_alternative(html_content, "text/html")
msg.send()
return HttpResponse('Trade reference data store in Database')
else:
return render(request, 'trade_references.html')
【问题讨论】:
标签: django django-views django-templates