daily pastebin goal
14%
SHARE
TWEET

Untitled

a guest Dec 10th, 2018 117 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def send_email(request):
  2.  
  3. try:
  4.     send_mail('Book request', 'email body', settings.EMAIL_HOST_USER, ['xyz@gmail.com'], fail_silently=False)
  5.  
  6.     #this message is not getting displayed in the same html page
  7.     messages.add_message(request, messages.SUCCESS, 'Email sent successfully.')
  8.  
  9. except EmailMessage:
  10.     messages.add_message(request, messages.SUCCESS, 'Error has occurred')
  11.    
  12. ......
  13.   rest of the code....
  14.  
  15.   {% if messages %}
  16.     <ul class="messages">
  17.         {% for message in messages %}
  18.             <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
  19.         {% endfor %}
  20.     </ul>
  21.   {% endif %}
  22.  
  23. {% endblock %}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top