У меня есть views.py
:
def buy(request):
if request.method=='POST':
form=forms.Purchase(request.POST)
if form.is_valid():
form.save()
user = Person.objects.filter(first_name=form.cleaned_data.get('first_name')).filter(last_name=form.cleaned_data.get('last_name')).first()
name=form.cleaned_data.get('first_name') + form.cleaned_data.get('last_name')
subject, from_email, to = 'Subject test1234', 'address@gmail.com', form.cleaned_data.get('email')
html_content = render_to_string('tickets/mail_template.html', {'first_name':user.first_name, 'imagelink':user.qr_image})
text_content = strip_tags(html_content)
msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
msg.attach_alternative(html_content, "text/html")
msg.send()
return redirect('thankyou')
else:
form=forms.Purchase()
return render(request, 'tickets/buy.html', {'form': form})
Внутри ImagField содержится файл изображения jpg, и я хочу, чтобы он отображался в отправляемом html-письме.
mail_template. html:
{% extends "event/base.html" %}
{% block content %}
<p>{{ first_name }}</p>
<img src= {{ imagelink }}>
{% endblock content%}
Первое_имя работает, а изображение - нет.