Advertisement
Guest User

Untitled

a guest
May 21st, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. EMAIL_HOST = 'smtp.gmail.com'
  2. EMAIL_HOST_USER = 'mymail@gmail.com'
  3. EMAIL_HOST_PASSWORD = 'mypassword'
  4. EMAIL_PORT = 587
  5. EMAIL_USE_TLS = True
  6.  
  7. def add_comment(request, wish_list_id):
  8. wish_list = get_object_or_404(Wish_list, pk=wish_list_id)
  9. if request.method == 'POST':
  10. form = Comment_to_wish_listForm(request.POST)
  11. if form.is_valid():
  12. newform=form.save(commit=False)
  13. newform.person = request.user
  14. newform.comment_to = wish_list
  15. newform.save()
  16. cd = form.cleaned_data
  17. send_mail(
  18. 'New comment',
  19. cd['text'],
  20. 'fromexample@gmail.com',
  21. ['toexample@gmail.com'],
  22. )
  23. return HttpResponseRedirect(reverse('friends_plans:comment', args=(wish_list.id,)))
  24. else:
  25. print form.errors
  26. else:
  27. form = Comment_to_wish_listForm()
  28. context_dict = {'form': form, 'wish_list': wish_list}
  29. return render(request, 'friends_plans/add_comment.html', context_dict)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement