Using EmailMultiAlternatives in Django but after sending email, then rendering problem

After sending html email by using EmailMultiAlternatives in Django, renderig problem occurred. I wanted to show the user email

an email is being sent to your email {{ email }}

But instead of displaying proper email address, it was displayed as follows "<django.core.mail.message.EmailMultiAlternatives object at 0x7f7b11bdffa0>"

How can I fix this problem?

views.py

#html email configuration
        html_content = render_to_string("basecamp/html_email-inquiry.html", 
        {'name': name, 'contact': contact, 'email': email, 
        'message': message,})
        text_content = strip_tags(html_content)
        email = EmailMultiAlternatives(
        "Inquiry",
        text_content,
        '',
        [email]
        )
        email.attach_alternative(html_content, "text/html")
        email.send()            
        
        return render(request, 'basecamp/inquiry_details.html',
                        {'name' : name, 'email': email, })

    else:
        return render(request, 'basecamp/inquiry1.html', {}) 

inquiry_details.html

<div class="py-md-6">
            <h1 class="text-light pb-1">Thank you! {{ name }}</h1>
            <br>
            <p class="fs-lg text-light">An email is being sent to your email now</span></p>

{{ name }} is displayed correct name but only email is not displayed proper email address. it is displayed like this; <django.core.mail.message.EmailMultiAlternatives object at 0x7f7b11bdffa0>

Django works in a synchronous way. So I made variable for rendering before html email configuration and return rendering that variable after html email codes.

the name of variable is called 'rendering'

views.py

rendering = render(request, 'basecamp/inquiry_details.html',
                        {'name' : name, 'email': email, })          
        
        # html email configuration
        html_content = render_to_string("basecamp/html_email-inquiry.html", 
        {'name': name, 'contact': contact, 'email': email,        
        'message': message,})
        text_content = strip_tags(html_content)
        email = EmailMultiAlternatives(
        "Inquiry",
        text_content,
        '',
        [email]
        )
        email.attach_alternative(html_content, "text/html")
        email.send()
            
        return rendering
    
    else:
        return render(request, 'basecamp/inquiry.html', {})

inquiry_details.html

<div class="py-md-6">              
            <h1 class="text-light pb-1">Thank you! {{ name }}</h1>            
            <p class="fs-lg text-light">An email is being sent to your email {{ email }} now</p>

it works fine !!! proper email address is now displayed well.

Back to Top