So my issue is that when i try to render_to_string and send the email with that message it shows only on email the HTML code as you can see on pictures
ps: the email receives well the name already fixed the only issue is the template not rendering
It should be something like this
With strip_tags
Those light grey strips is where it should be some variables like name, etc
I used {{client.name}} for example
Now it render the html but not with the variables from database it showed like you can see above
- BrunoSeixas 4 years, 8 months agoif you like to add variable then add the context ={}
dictionary.
Example render_to_string('base.html', {'context': 'values'})
Okay but how can i send users into context because i could send like client.name and marketingup but when i try to
{% for upsell in marketingup %} {% if upsell.user == user%} it doenst render anything and leaves a blank space in there
- BrunoSeixas 4 years, 8 months agoMay be try this,
def index(request):
if not request:
context = {'param1':'value1'}
return render_to_string('myapp/index.html', RequestContext(None, context))
else:
#render as usual
render(request, 'myapp/index.html', context)
pass
by the way is there a way to make text bigger or smaller?? where i want on the html to appear on the email
- BrunoSeixas 4 years, 8 months agoi had with bootstrap but didnt went well xD i was using <hr> and it didnt showed them on the email
and i have like <h1> and <h4> and there is no difference
- BrunoSeixas 4 years, 8 months agoadd html_message
in your send_mail and try it out,
send_mail(
'email title',
msg_plain,
'some@sender.com',
['some@receiver.com'],
html_message=msg_html,
)
what is the msg_html?? is it render_to_string('message.html', context) ?
- BrunoSeixas 4 years, 8 months agobut then shows this __init__() got an unexpected keyword argument 'html_message'
- BrunoSeixas 4 years, 8 months agoHow about this one, mail = EmailMultiAlternatives(subject, message, from_email, recipient_list) if message: mail.attach_alternative(message, 'text/html') return mail.send() if doesnt work then try change from EmailMultiAlternatives to send_mail
- VengatCan you confirm about this one?. Is this resolved or not? If not resolved let me at the earliest , we can investigate further.
- VengatIn future, if the issue resolved, close the ticket from your end at the earliest.
- Vengat
@Brunoseixas Can you try the below code,
And then send mail using this message variable.
Hereafter, send me your code when you submit the ticket along with your screenshot.