Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- EMAIL_HOST = 'smtp.gmail.com'
- EMAIL_HOST_USER = 'mymail@gmail.com'
- EMAIL_HOST_PASSWORD = 'mypassword'
- EMAIL_PORT = 587
- EMAIL_USE_TLS = True
- def add_comment(request, wish_list_id):
- wish_list = get_object_or_404(Wish_list, pk=wish_list_id)
- if request.method == 'POST':
- form = Comment_to_wish_listForm(request.POST)
- if form.is_valid():
- newform=form.save(commit=False)
- newform.person = request.user
- newform.comment_to = wish_list
- newform.save()
- cd = form.cleaned_data
- send_mail(
- 'New comment',
- cd['text'],
- 'fromexample@gmail.com',
- ['toexample@gmail.com'],
- )
- return HttpResponseRedirect(reverse('friends_plans:comment', args=(wish_list.id,)))
- else:
- print form.errors
- else:
- form = Comment_to_wish_listForm()
- context_dict = {'form': form, 'wish_list': wish_list}
- return render(request, 'friends_plans/add_comment.html', context_dict)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement