0

I have a email template that I want to pass values in to. This I achieve by the following code. I wish to know how to pass 2 variables that way

    subject = request.POST.get('inq_sub')
    message = request.POST.get('inq_mes')
    html_content = render_to_string('customer_inquiry.html',{'subject': subject})

1 Answer 1

1

You also need to pass the message in render_to_string like:

html_content = render_to_string('customer_inquiry.html',{'subject': subject, 'message':message})

Inside customer_inquiry.html you can use your variable like this:

<h3>{{subject}}</h3>
<p>{{message}}</p>

Here is render_to_string from the doc: https://docs.djangoproject.com/fr/2.2/topics/templates/#django.template.loader.render_to_string

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.