def order(request):
name = request.GET.get('name')
email = request.GET.get('email')
check_bots = request.GET.get('last_name')
service = request.GET.get('service', 0) or 'r'
remote_addr = request.environ['REMOTE_ADDR']
order = OrderDetail.objects.create(name=name, contacts=email, service=service)
t = Template('''Здравствуйте, пришла заявка с сайта site.ru<br>Имя: {{name}}<br>Контакт: {{email}}<br>Услуга: {{service}}<br>IP адрес отправителя: {{remote_addr}}''')
if check_bots == '':
# так же пробовал писать if not check_bots :
body = t.render(Context({'name': name, 'remote_addr': remote_addr, 'email': email, 'service': order.get_service_display}))
msg = EmailMessage('site.ru', body, config.EMAIL_FROM, [x.strip() for x in config.EMAIL_TO.split(',')])
msg.content_subtype = "html"
msg.send()
return redirect(Page.objects.filter(reverse_id=service)[0].get_absolute_url())