【发布时间】:2014-07-09 08:21:46
【问题描述】:
我对 django 和构建我的第一个应用程序比较陌生。
尝试通过该网站进行搜索,但终其一生都找不到所需的相关信息。
我希望将确认电子邮件发送到联系表单上输入的电子邮件地址。我已经看到了发送到选定地址或用户的示例,但我似乎无法弄清楚如何将邮件发送到表单中输入的电子邮件。
非常感谢任何帮助!
models.py:
from django.db import models
class Quote(models.Model):
name = models.CharField(max_length=200, blank=False, null=False, verbose_name="your name")
email = models.EmailField(max_length=255, blank=False, null=False)
created_at = models.DateTimeField(auto_now=True)
def __unicode__(self):
return self.name
forms.py:
class QuoteForm(forms.ModelForm):
class Meta:
model = Quote
views.py:
class QuoteView(CreateView):
model = Quote
form_class = QuoteForm
template_name = "quote/quote.html"
success_url = "/quote/success/"
def form_valid(self, form):
super(QuoteView,self).form_valid(form)
return HttpResponseRedirect(self.get_success_url())
class QuoteSuccessView(TemplateView):
template_name = "quote/quote-complete.html"
【问题讨论】:
标签: python django django-forms django-views