Last active
December 14, 2017 15:46
-
-
Save ErickMwazonga/4eb6037f0af61bc854c603c4a3fa5058 to your computer and use it in GitHub Desktop.
feedback_mail_admins.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.mail import mail_admins | |
def feedback(request): | |
if request.method == 'POST': | |
f = FeedbackForm(request.POST) | |
if f.is_valid(): | |
name = f.cleaned_data['name'] | |
sender = f.cleaned_data['email'] | |
subject = "You have a new Feedback from {}:{}".format(name, sender) | |
message = "Subject: {}\n\nMessage: {}".format(f.cleaned_data['subject'], f.cleaned_data['message']) | |
mail_admins(subject, message) | |
f.save() | |
return redirect('feedback') | |
else: | |
f = FeedbackForm() | |
return render(request, 'blog/feedback.html', {'form': f}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment